diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index 55a14e255d..2e8857a8fa 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -94,14 +94,6 @@ export default () => { n.name === 'dynamic-sampling').children} /> - - n.name === 'delightful-developer-metrics').children} - /> -
  • diff --git a/src/docs/delightful-developer-metrics/images/ddm-dashboards-alers.png b/src/docs/delightful-developer-metrics/images/ddm-dashboards-alers.png deleted file mode 100644 index 536bb3b348..0000000000 Binary files a/src/docs/delightful-developer-metrics/images/ddm-dashboards-alers.png and /dev/null differ diff --git a/src/docs/delightful-developer-metrics/images/ddm.png b/src/docs/delightful-developer-metrics/images/ddm.png deleted file mode 100644 index f8e1d7be7d..0000000000 Binary files a/src/docs/delightful-developer-metrics/images/ddm.png and /dev/null differ diff --git a/src/docs/delightful-developer-metrics/images/sidebar.png b/src/docs/delightful-developer-metrics/images/sidebar.png deleted file mode 100644 index 976b5fdd85..0000000000 Binary files a/src/docs/delightful-developer-metrics/images/sidebar.png and /dev/null differ diff --git a/src/docs/delightful-developer-metrics/images/sidebar2.png b/src/docs/delightful-developer-metrics/images/sidebar2.png deleted file mode 100644 index c70d4b8524..0000000000 Binary files a/src/docs/delightful-developer-metrics/images/sidebar2.png and /dev/null differ diff --git a/src/docs/delightful-developer-metrics/index.mdx b/src/docs/delightful-developer-metrics/index.mdx deleted file mode 100644 index 29a6aef974..0000000000 --- a/src/docs/delightful-developer-metrics/index.mdx +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: Sentry Developer Metrics ---- - -In this tutorial, you will learn how to start using the new Metrics project, also known as DDM. You will understand how to collect metrics in our `sentry` codebase or via the SDK and how to see them in the new DDM UI. You will also learn some basic information about metrics, and tricks to avoid misusing them. - -![DDM UI](/images/ddm.png) - -## What Are Metrics - -Metrics are **numerical values that can track anything about your environment over time**, from latency to error rates to user signups. At Sentry, we collect a lot of metrics, as they provide a comprehensive understanding of the health of our systems. - -## Metric Types - -Metrics at Sentry come in different flavors, in order to help you track your data in the most efficient and cost-effective way. The types of metrics we currently support are: - -- **Counters** → they track a value that can only be incremented. -- **Distributions** → they track a list of values over time in on which you can perform aggregations like `max`, `min`, `avg`. -- **Gauges** → they track a value that can go up and down. -- **Sets** → they track a set of values on which you can perform aggregations such as `count_unique`. - -## Tags and Cardinality - -You might have heard the words cardinality explosion when talking about metrics. In this guide, we will try to explain what this seemingly complex term means. - -Suppose you are trying to count the votes on your dinner, and each vote has two properties: - -- **Cuisine Type** → type of the restaurant (e.g., Asian, Italian, German). -- **Price** → price range of the restaurant (e.g. $, $$, $$). - -How would you count all the votes by type and price? The simple solution is to create multiple boxes that contain all the votes for the combinations of type and price (e.g., Italian-$, German-$$). If you have 3 types and 3 prices, the resulting number of boxes you need is 9, which is already quite a lot. - -Now, a friend comes and says, let's add another property which is the day of the month, which has 31 values. Now all the combinations go from `3 × 3 = 9` to `3 × 3 × 31 = 279`, pretty insane. This is what is known as a cardinality explosion. - -To prevent such an explosion, the simple solution is to try and use tags, **whose number of distinct values is low**. The end goal is to have a small product of the tag values. - - -## Learn More About Sentry Developer Metrics - - diff --git a/src/docs/delightful-developer-metrics/sending-metrics-abstraction.mdx b/src/docs/delightful-developer-metrics/sending-metrics-abstraction.mdx deleted file mode 100644 index d1cab2c012..0000000000 --- a/src/docs/delightful-developer-metrics/sending-metrics-abstraction.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: Sending Metrics (Abstraction) -sidebar_order: 2 ---- - - - -Do not use the internal abstraction for sending metrics at this stage. We want to dogfood SDK methods to feel the ergonomics and the experience our customers will get. [Use this instead.](/delightful-developer-metrics/sending-metrics-sdk/) - - - -## Sentry Metrics Abstraction - -In order to make metrics collection uniform across the entire `sentry` codebase, we have an abstraction known as `MetricsBackend` which exposes metrics collection with three methods. - -- `incr` → emits a counter metric. -- `timing` → emits a distribution metric (with the `second` unit on Sentry metrics). -- `gauge` → emits a gauge metric (temporarily emits a counter, until the infra work is done). - -Each method has three main parameters: - -- `key` → the name that uniquely identifies the metric. You will use the name to specify the metric when you want to plot it. -- `value` → the value of the value. You will plot the value of the metric. -- `tags` → the tags of the metric. You will use the tags to attach metadata to the metric, which can be helpful for aggregations. - -To learn more about `MetricsBackend`, visit [Internal Metrics](/services/metrics/). - -## Using the `MetricsBackend` - -To use the metrics backend you will first have to import it: - -```python -from sentry.utils import metrics -``` - -Once imported, you can start emitting metrics: - -```python -# Emit a counter. -metrics.incr( - "counter_name", - tags={"platform": platform} -) - -# Emit a distribution. -metrics.distribution( - "gauge_name", - 10, - tags={"nation": nation}, - unit="second", -) - -# Emit a gauge. -metrics.gauge( - "gauge_name", - 10, - tags={"nation": nation} -) - -# Emit a distribution (with default time-based unit). -metrics.timing( - "distribution_name", - 100, - tags={"user_segment": user_segment} -) -``` - -If you want to measure how much time a specific piece of code takes, you can use: - -```python -# Emit a distribution metric of the execution time of the function. -with metrics.timer("my_func"): - my_func() -``` - - - -The current metrics sample rate is 5% with the goal of getting to 100% soon. - - - - - -## Details about the `MetricsBackend` - -The current implementation of the `MetricsBackend` is known as `CompositExperimentalMetricsBackend`. It's a backend that forwards your metrics to both **Datadog** and **Sentry**. For this reason, you will be able to see your metrics on both platforms, even though the end goal is to use our own metrics product when it is mature enough. More details [here](/services/metrics/#composit-experimental-backend). - -*Keep in mind that due to scale implications, we might sample the metrics sent to Sentry. This is only temporary but it means that for now if you need high-fidelity metrics, we still suggest you refer to Datadog.* diff --git a/src/docs/delightful-developer-metrics/sending-metrics-sdk.mdx b/src/docs/delightful-developer-metrics/sending-metrics-sdk.mdx deleted file mode 100644 index 829532387c..0000000000 --- a/src/docs/delightful-developer-metrics/sending-metrics-sdk.mdx +++ /dev/null @@ -1,146 +0,0 @@ ---- -title: Sending Metrics (SDK) -sidebar_order: 1 ---- - - - -This is the recommended way to send metrics. We want to dogfood SDK methods to feel the ergonomics and the experience our customers will get. - - - -## Using Python SDK - -In case you are looking to use the new metrics feature directly from the Python SDK you can do it as follows. - -First, you have to use at least the `1.38.0` version of the `sentry-python` SDK and add that as your dependency. For example: - -``` -sentry-sdk @ 1.38.0 -``` - -Once the SDK is installed you have to add experimental flag into your SDK init: - -```python -import sentry_sdk - -sentry_sdk.init( - ... - _experiments={ - # Turns on the metrics module (required) - "enable_metrics": True, - # Enables sending of code locations for metrics (recommended) - "metric_code_locations": True, - }, -) -``` - -Ensure you have [feature flags for both ingestion and UI](/delightful-developer-metrics/ui/#enabling-the-ui) enabled. - -Then you can use the metrics method as follows: - -```python -from sentry_sdk import metrics - -# Emit a counter -metrics.incr( - key="my_counter", - value=2, - tags=tags, -) - -# Emit a distribution -metrics.distribution( - key="my_distribution", - value=15.0, - tags=tags, - # You can also specify a unit if you want - unit="second", -) - -# Emit a set -metrics.set( - key="my_set", - value="john", - tags=tags, -) - -# Emit a gauge -metrics.gauge( - key="my_gauge", - value=10, - tags=tags, -) -``` - -If you want to measure how much time a specific piece of code takes, you can use: - -```python -from sentry_sdk import metrics - -# Emit a distribution metric of the execution time of the function. -with metrics.timing("my_function"): - pass - -@metrics.timing("my_function") -def my_function(): - pass -``` - - - -The current metrics sample rate is 5% with the goal of getting to 100% soon. - - - - -As of now, only the Python SDK is supporting the new metrics features but we are working on supporting metrics in the JavaScript and Rust SDKs next. - - -## Units Support - -The following units are supported out of the box (but the system also allows you to pass your own unit if you need): - -```bash -"nanosecond", -"microsecond", -"millisecond", -"second", -"minute", -"hour", -"day", -"week", -"bit", -"byte", -"kilobyte", -"kibibyte", -"megabyte", -"mebibyte", -"gigabyte", -"gibibyte", -"terabyte", -"tebibyte", -"petabyte", -"pebibyte", -"exabyte", -"exbibyte", -"ratio", -"percent", -"none" -``` - - - -Please note that if you change the unit of a metric, it will be extracted as a new metric. - - - -## Automatic Tags Extraction - -Since DDM has the goal of being tightly integrated into Sentry, the `sentry-python` implementation already automatically adds the following tags to your metric: - -- `transaction` -- `release` -- `environment` - -*As we will see later on, these special tags are recognized by the DDM UI and will prompt you with helpful actions.* diff --git a/src/docs/delightful-developer-metrics/ui.mdx b/src/docs/delightful-developer-metrics/ui.mdx deleted file mode 100644 index 4da3d5e909..0000000000 --- a/src/docs/delightful-developer-metrics/ui.mdx +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: UI -sidebar_order: 3 ---- - -## Plotting Metrics - -In order to plot your metrics, we have developed a prototype user interface, which you can look at as a scratchpad. A scratchpad in our vision is essentially a temporary dashboard that is stored only locally in your browser and has the capability to be shared since the information about the dashboard is **encoded into the URL**. - -## Enabling the UI - -The first step towards using the UI is to enable it, since right now it’s feature flagged. The following feature flag is needed: - -- `organizations:custom-metrics` - -See our guide on [feature flags](/feature-flags/) to learn how to do that. - -Once you have the feature flag enabled you will magically see a new sidebar item called Metrics and now the fun begins! - -![Metrics Sidebar](/images/sidebar2.png) - -## Using the UI - -The UI is quite straightforward. You will see an option to add a widget, and each widget will have a series of properties. These properties include the metric you want to plot (identified by name), the aggregate operation to perform, the grouping method, and the display type. - -![Metrics UI](/images/ddm.png) - -You will also be able to **save your scratchpad**. This means that Sentry will store the representation of the scratchpad in your local storage. This allows you to maintain multiple scratchpads during an exploration. - -## Dashboards and Alerts - -You can alert on custom metrics. As always, you can create these alerts either from the Metrics page or by using the Alerts Wizard. - -Metrics also play nicely with Dashboards. You can plot custom metrics in the Metrics tab and then later save them to a dashboard or go through the Dashboards directly. - -![Metrics Dashboards and Alerts](/images/ddm-dashboards-alers.png) - - - -## 🙏 Now have fun and don’t forget to give us feedback on [GitHub](https://github.com/getsentry/sentry/discussions/58584) diff --git a/src/docs/sdk/metrics.mdx b/src/docs/sdk/metrics.mdx index ae145e8873..ffb7b111eb 100644 --- a/src/docs/sdk/metrics.mdx +++ b/src/docs/sdk/metrics.mdx @@ -6,8 +6,7 @@ sidebar_order: 13 Sentry supports the emission of pre-aggregated metrics information via the `statsd` envelope item. This emission bypasses relay-side sampling and assumes a client side aggregator. In the product these are referred to as "custom metrics" and internally -the system sometimes carries the name "ddm" ([delightful developer -metrics](/delightful-developer-metrics/)). The functionality sits on top of the +the system sometimes carries the name "DDM". The functionality sits on top of the generics metrics platform which is also used for span and transaction level metrics. diff --git a/src/docs/services/metrics.mdx b/src/docs/services/metrics.mdx index 4ddb21ad6b..e80ed202c5 100644 --- a/src/docs/services/metrics.mdx +++ b/src/docs/services/metrics.mdx @@ -6,6 +6,66 @@ Sentry provides an abstraction called ‘metrics’ which is used for internal m The default backend simply discards them (though some values are still kept in the internal time series database). +## Sentry Metrics Abstraction + +In order to make metrics collection uniform across the entire `sentry` codebase, we have an abstraction which exposes metrics collection with three methods. + +- `incr` → emits a counter metric. +- `timing` → emits a distribution metric (with the `second` unit on Sentry metrics). +- `gauge` → emits a gauge metric (temporarily emits a counter, until the infra work is done). + +Each method has three main parameters: + +- `key` → the name that uniquely identifies the metric. You will use the name to specify the metric when you want to plot it. +- `value` → the value of the value. You will plot the value of the metric. +- `tags` → the tags of the metric. You will use the tags to attach metadata to the metric, which can be helpful for aggregations. + +To use the metrics abstraction you will first have to import it: + +```python +from sentry.utils import metrics +``` + +Once imported, you can start emitting metrics: + +```python +# Emit a counter. +metrics.incr( + "counter_name", + tags={"platform": platform} +) + +# Emit a distribution. +metrics.distribution( + "gauge_name", + 10, + tags={"nation": nation}, + unit="second", +) + +# Emit a gauge. +metrics.gauge( + "gauge_name", + 10, + tags={"nation": nation} +) + +# Emit a distribution (with default time-based unit). +metrics.timing( + "distribution_name", + 100, + tags={"user_segment": user_segment} +) +``` + +If you want to measure how much time a specific piece of code takes, you can use: + +```python +# Emit a distribution metric of the execution time of the function. +with metrics.timer("my_func"): + my_func() +``` + ## Statsd Backend ```python @@ -86,7 +146,7 @@ LOGGING['handlers']['console:metrics'] = { ## Composit Experimental Backend -The `CompositeExperimentalMetricsBackend` reports all operations to both Datadog and Sentry. More information about why and how we are using it can be found in [Sentry Developer Metrics](/delightful-developer-metrics/sending-metrics-abstraction/). +The current implementation of the `MetricsBackend` is known as `CompositExperimentalMetricsBackend`. The `CompositeExperimentalMetricsBackend` reports all operations to both Datadog and Sentry. For this reason, you will be able to see your metrics on both platforms. ```python SENTRY_METRICS_BACKEND = "sentry.metrics.composite_experimental.CompositeExperimentalMetricsBackend"