diff --git a/docs/platforms/ruby/common/metrics/index.mdx b/docs/platforms/ruby/common/metrics/index.mdx new file mode 100644 index 00000000000000..6c65adceb391e1 --- /dev/null +++ b/docs/platforms/ruby/common/metrics/index.mdx @@ -0,0 +1,34 @@ +--- +title: Set Up Metrics +sidebar_title: Metrics +description: "Metrics allow you to send, view and query counters, gauges and measurements sent from your applications within Sentry." +sidebar_order: 7 +sidebar_section: features +beta: true +--- + + + +This feature is currently in open beta. Please reach out on [GitHub](https://github.com/getsentry/sentry/discussions/102275) if you have feedback or questions. Features in beta are still in-progress and may have bugs. We recognize the irony. + + + +Sentry metrics help you pinpoint and solve issues that impact user experience and app performance by measuring the data points that are important to you. You can track things like processing time, event size, user signups, and conversion rates, then correlate them back to tracing data in order to get deeper insights and solve issues faster. + +Once in Sentry, these metrics can be viewed alongside relevant errors, and searched using their individual attributes. + +## Requirements + + + +## Usage + + + +## Options + + + +## Default Attributes + + diff --git a/docs/product/explore/metrics/getting-started/index.mdx b/docs/product/explore/metrics/getting-started/index.mdx index abf06fc327b6e8..86e1349c92cc85 100644 --- a/docs/product/explore/metrics/getting-started/index.mdx +++ b/docs/product/explore/metrics/getting-started/index.mdx @@ -235,16 +235,19 @@ To set up Sentry Metrics, use the links below for supported SDKs. After it's bee url="/platforms/php/guides/laravel/metrics/" /> -## Upcoming SDKs - -We're actively working on adding Metrics functionality to additional SDKs. Check out these GitHub issues for the latest updates: +### Ruby - + +## Upcoming SDKs + +We're actively working on adding Metrics functionality to additional SDKs. Check out these GitHub issues for the latest updates: + - + + + + diff --git a/platform-includes/metrics/options/ruby.mdx b/platform-includes/metrics/options/ruby.mdx new file mode 100644 index 00000000000000..0d21b409226f19 --- /dev/null +++ b/platform-includes/metrics/options/ruby.mdx @@ -0,0 +1,35 @@ +#### before_send_metric + +To filter metrics, or update them before they are sent to Sentry, you can use the `before_send_metric` option. If the callback returns `nil`, the metric is not emitted. Attributes can also be updated in the callback function. + +```ruby +Sentry.init do |config| + config.dsn = "___PUBLIC_DSN___" + + config.before_send_metric = lambda do |metric| + # filter metric + return nil if metric.name == "removed-metric" + + # add attributes + metric.attributes[:extra] = "foo" + + # remove attributes + metric.attributes.delete(:browser) if metric.attributes.has_key?(:browser) + + metric + end +end +``` + +The `before_send_metric` function receives a `MetricEvent` object, and should return a `MetricEvent` object if you want it to be sent to Sentry, or `nil` if you want to discard it. + +The `MetricEvent` object has the following attributes: + +- `name`: (`String`) The name of the metric. +- `type`: (`Symbol`) - one of `:counter`, `:gauge`, `:distribution`) The type of metric. +- `value`: (`Float`) The numeric value of the metric. +- `unit`: (`Optional[String]`) The unit of measurement for the metric value. +- `attributes`: (`Hash`) Additional attributes to be sent with the metric. +- `timestamp`: (`Time`) Timestamp indicating when the metric was recorded. +- `trace_id`: (`Optional[String]`) The trace ID of the trace this metric belongs to. +- `span_id`: (`Optional[String]`) The span ID of the span that was active when the metric was emitted. diff --git a/platform-includes/metrics/requirements/ruby.mdx b/platform-includes/metrics/requirements/ruby.mdx new file mode 100644 index 00000000000000..0be96e525e2073 --- /dev/null +++ b/platform-includes/metrics/requirements/ruby.mdx @@ -0,0 +1,11 @@ +Metrics for Python are supported in Sentry Ruby SDK version `6.3.0` and above. + +```bash +gem install sentry-ruby +``` + +Or add it to your Gemfile: + +```ruby +gem "sentry-ruby" +``` diff --git a/platform-includes/metrics/usage/ruby.mdx b/platform-includes/metrics/usage/ruby.mdx new file mode 100644 index 00000000000000..b47ece937a09cb --- /dev/null +++ b/platform-includes/metrics/usage/ruby.mdx @@ -0,0 +1,50 @@ +Metrics are enabled by default. Once you initialize the SDK, you can send metrics using the `Sentry.metrics` APIs. + +The `metrics` namespace exposes three methods that you can use to capture different types of metric information: `count`, `gauge`, and `distribution`. + +## Emit a Counter + +Counters are one of the more basic types of metrics and can be used to count certain event occurrences. + +To emit a counter, do the following: + +```ruby +# Record five total button clicks +Sentry.metrics.count( + "button_click", + value: 5, + attributes: { browser: "Firefox", app_version: "1.0.0" } +) +``` + +## Emit a Distribution + +Distributions help you get the most insights from your data by allowing you to obtain aggregations such as `p90`, `min`, `max`, and `avg`. + +To emit a distribution, do the following: + +```ruby +# Add '15.0' to a distribution used for tracking the loading times per page. +Sentry.metrics.distribution( + "page_load", + 15.0, + unit: "millisecond", + attributes: { page: "/home" } +) +``` + +## Emit a Gauge + +Gauges let you obtain aggregates like `min`, `max`, `avg`, `sum`, and `count`. They can be represented in a more space-efficient way than distributions, but they can't be used to get percentiles. If percentiles aren't important to you, we recommend using gauges. + +To emit a gauge, do the following: + +```ruby +# Add '15.0' to a gauge used for tracking the loading times for a page. +Sentry.metrics.gauge( + "page_load", + 15.0, + unit: "millisecond", + attributes: { "page": "/home" } +) +``` diff --git a/src/middleware.ts b/src/middleware.ts index e662838f639ac6..52609c12f0df02 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1770,10 +1770,6 @@ const USER_DOCS_REDIRECTS: Redirect[] = [ to: '/platforms/javascript/guides/:guide/opentelemetry/', }, // START redirecting deprecated generic metrics docs to concepts - { - from: '/platforms/ruby/metrics/', - to: '/concepts/key-terms/tracing/span-metrics/', - }, { from: '/platforms/java/metrics/', to: '/concepts/key-terms/tracing/span-metrics/',