You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: develop-docs/application-architecture/dynamic-sampling/extrapolation.mdx
+20-31Lines changed: 20 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,34 +3,27 @@ title: Extrapolation
3
3
sidebar_order: 5
4
4
---
5
5
6
-
Dynamic sampling reduces the amount of data ingested, for reasons of both performance and cost. When configured, a fraction of the data is ingested according to the specified sample rate of a project: if you sample at 10% and initially have 1000 requests to your site in a given timeframe, you will only see 100 spans in Sentry. Without making up for the sample rate, any metrics derived from these spans will misrepresent the true volume of the application. When different parts of the application have different sample rates, there will even be a bias towards some of them, skewing the total volume towards parts with higher sample rates. This bias especially impacts numerical attributes like latency, reducing their accuracy. To account for this fact, Sentry uses extrapolation to smartly combine the data to account for sample rates.
6
+
Client and server-side sampling reduces the amount of data ingested, to help with both performance and cost. When configured, a fraction of the data is ingested according to the specified sample rates within a project. For example, if you sample 10% of 1000 requests to your site in a given timeframe, you will see 100 spans in Sentry.
7
7
8
-
### Accuracy & Expressiveness
9
-
What happens during extrapolation, how does one handle this type of data, and when is extrapolated data accurate and expressive? Let's start with some definitions:
8
+
Without accounting for the lower request volume due to the sample rate, any metrics derived from these spans will misrepresent the true volume of the application. Perhaps more importantly, when different parts of your application have different sample rates, attention may be skewed with a bias towards parts with higher sample rates. This bias especially impacts numerical attributes like latency, reducing their accuracy. To account for this, Sentry uses extrapolation to a) derive a "true" volume of each part of your application and b) combine the extrapolated data from different parts of the application to provide a more wholistic view of the application's performance.
10
9
11
-
-**Accuracy** refers to data being correct. For example, the measured number of spans corresponds to the actual number of spans that were executed. As sample rates decrease, accuracy also goes down because minor random decisions can influence the result in major ways.
12
-
-**Expressiveness** refers to data being able to express something about the state of the observed system. Expressiveness refers to the usefulness of the data for the user in a specific use case.
13
-
14
-
### Modes
15
-
Given these properties, there are two modes that can be used to view data in Sentry: default mode and sample mode.
16
-
17
-
-**Default mode** extrapolates the ingested data as outlined below.
18
-
-**Sample mode** does not extrapolate and presents exactly the data that was ingested.
10
+
### Benefits of Extrapolation
11
+
For high-volume organizations, sampling is a way to control costs and reduce volume, as well as reduce the amount of redundant data sent to Sentry. Extrapolation is a way to account for the lower request volume due to the sample rate, and to provide a more wholistic view of the application's performance. Here are some of the benefits of extrapolation:
19
12
20
-
Depending on the context and the use case, one mode may be more useful than the other. Generally, default mode is useful for all queries that aggregate on a dataset of sufficient volume. As absolute sample size decreases below a certain limit, default mode becomes less and less expressive. There are scenarios where the user needs to temporarily switch between modes, for example, to examine the aggregate numbers first and dive into the number of samples for investigation. In both modes, the user may investigate single samples to dig deeper into the details.
13
+
-**The numbers correspond to the real world**: When data is sampled, there is some math you need to do to infer what the real numbers are, e.g., when you have 1000 samples at 10% sample rate, there are 10000 requests to your application. With extrapolation, you don't have to know your sample rate to understand what your application is actually doing. Instead, while viewing charts, you see the real behavior without additional knowledge or math required on your end.
21
14
22
-
### Benefits of Extrapolation
23
-
At first glance, extrapolation may seem unnecessarily complicated. However, for high-volume organizations, sampling is a way to control costs and egress volume, as well as reduce the amount of redundant data sent to Sentry. Why don't we just show the user the data they send? We don't just extrapolate for fun; it actually has some major benefits for the user:
15
+
-**Steady timeseries when sample rates change**: Whenever you change sample rates, both the count and possibly the distribution of the values will change in some way. When you switch the sample rate from 10% to 1% for whatever reason, there will be a sudden change in all associated metrics. Extrapolation corrects for this, so your graphs are steady, and your alerts track on the same data, regardless of the sample rate.
24
16
25
-
-**The numbers correspond to the real world**: When data is sampled, there is some math you need to do to infer what the real numbers are, e.g., when you have 1000 samples at 10% sample rate, there are 10000 requests to your application. With extrapolation, you don't have to know your sample rate to understand what your application is actually doing. Instead, you get a view of the real behavior without additional knowledge or math required on your end.
17
+
-**Combining different sample rates**: When your endpoints don't have the same sample rate, how are you supposed to know the true p90 when one of your endpoints is sampled at 1% and another at 100%, but all you get is the aggregate of the samples? Extrapolation calculates the true p90 by combining the data from all endpoints, weighted by the sample rate.
26
18
27
-
-**Steady timeseries when sample rates change**: Whenever you change sample rates, both the count and possibly the distribution of the values will change in some way. When you switch the sample rate from 10% to 1% for whatever reason, there will be a sudden change in all associated metrics. Extrapolation corrects for this, so your graphs are steady, and your alerts don't fire when this happens.
28
-
-**Combining different sample rates**: When your endpoints don't have the same sample rate, how are you supposed to know the true p90 when one of your endpoints is sampled at 1% and another at 100%, but all you get is the aggregate of the samples?
19
+
**Note:** When a sample rate is too low, there may be a low confidence in the extrapolated data. When this is the case, you should consider increasing the sample rate, widening your time range or filter, or turning off extrapolation.
Sentry allows the user to aggregate data in different ways - the following aggregates are generally available, along with whether they are extrapolatable or not:
26
+
Sentry allows you to aggregate data in different ways - the following aggregates are generally available, along with whether they are extrapolatable or not:
34
27
35
28
|**Aggregate**|**Can be extrapolated?**|
36
29
| --- | --- |
@@ -42,12 +35,12 @@ Sentry allows the user to aggregate data in different ways - the following aggre
42
35
| max | no |
43
36
| count_unique | no |
44
37
45
-
Each of these aggregates has its own way of dealing with extrapolation, due to the fact that e.g., counts have to be extrapolated in a slightly different way from percentiles. While `min` and `max` are technically percentiles, we currently do not offer extrapolation due to the decreased stability of extreme aggregates when sampling. For example, the `p50` will also be more stable than the `p99`; the `min` and `max` are just extreme cases.
38
+
Each of these aggregates has its own way of dealing with extrapolation, due to the fact that, for example, counts have to be extrapolated in a slightly different way from percentiles. While `min` and `max` are technically percentiles, we currently do not offer extrapolation due to the decreased stability of extreme aggregates when sampling. For example, the `p50` will also be more stable than the `p99`; the `min` and `max` are just extreme cases.
46
39
47
40
### Extrapolation for different aggregates
48
41
To extrapolate, sampling weights are calculated as `1/sample rate`. The sampling weights of each row are then used in the following ways:
49
42
50
-
-**Count**: Calculate a sum of the sampling weight
43
+
-**Count**: Calculate a sum of the sampling weight.
51
44
Example: the query `count()` becomes `round(sum(sampling_weight))`.
52
45
-**Sum**: Multiply each value with `sampling_weight`.
53
46
Example: the query `sum(foo)` becomes `sum(foo * sampling_weight)`
-**Percentiles**: Calculate the weighted percentiles with sampling weight.
57
50
Example: the query `percentile(0.95)(foo)` becomes `weightedPercentile(0.95)(foo, sampling_weight)`.
58
51
59
-
As long as there are sufficient samples, the sample rate itself does not matter as much, but due to the extrapolation mechanism, what would be a fluctuation of a few samples may turn into a much larger absolute impact, e.g., in terms of the view count. Of course, when a site gets billions of visits, a fluctuation of 100,000 via the noise introduced by a sample rate of 0.00001 is not as critical.
52
+
As long as there are sufficient samples, the sample rate itself does not matter as much, but due to the extrapolation mechanism, a fluctuation of a few samples in a small sample set may turn into a much larger absolute impact. When a site gets billions of visits, a fluctuation of 100,000 via the noise introduced by a sample rate of 0.00001 is not as critical.
60
53
61
54
## How to deal with extrapolation in the product?
62
55
@@ -72,20 +65,16 @@ In new product surfaces, the question of whether to use extrapolated vs. non-ext
72
65
- Does the user care more about a truthful estimate of the aggregate data or about the actual events that happened?
73
66
- Some scenarios, like visualizing metrics over time, are based on aggregates, whereas a case of debugging a specific user's problem hinges on actually seeing the specific events. The best mode depends on the intended usage of the product.
74
67
75
-
### Switching to Sample Mode
76
-
Sample mode is designed to help users investigate specific events. Here are two common scenarios where it makes the most sense:
77
-
78
-
1.**When both sample rate and event volume are low**: Extrapolation becomes less reliable in these cases. You can either increase your sample rate to improve accuracy, or switch to sample mode to examine the actual events - both are valid approaches depending on the user's needs.
79
-
2.**When you have a high sample rate but still see low event volumes**: In this case, increasing the sample rate won't help capture more data, and sample mode will give you a clearer picture of the events you do have.
68
+
### When to Turn Off Extrapolation
69
+
While extrapolation is usually helpful, if you are exclusively looking to confirm your sampling usage or look exclusively at sampled data, you can turn off extrapolation.
80
70
81
-
### Opting Out of Extrapolation
82
-
Users may want to opt out of extrapolation for different reasons. It is always possible to set the sample rate for specific events to 100% and therefore send all data to Sentry, implicitly opting out of extrapolation and behaving in the same way as sample mode. Depending on their configuration, users may need to change Dynamic Sampling settings or their SDK's traces sampler callback for this.
71
+
You can always increase your sample rate to 100% to examine all events if traffic is too low to be otherwise useful via extrapolation or sampling.
83
72
84
73
### Confidence
85
-
When users filter on data that has a very low count but also a low sample rate, yielding a highly extrapolated but low-sample dataset, developers and users should be careful with the conclusions they draw from the data. The storage platform provides confidence intervals along with the extrapolated estimates for the different aggregation types to indicate when there is elevated uncertainty in the data. These types of datasets are inherently noisy and may contain misleading information. When this is discovered, the user should either be very careful with the conclusions they draw from the aggregate data or switch to non-default mode for investigation of the individual samples.
74
+
When there is not enough data to properly extrapolate, Sentry will indicate lowconfidence in the data. If this message is not present, Sentry has a high confidence in the data.
86
75
87
76
## **Conclusion**
88
77
89
78
- Extrapolation offers benefits in many parts of the product but brings some inherent complexity.
90
-
- Some aggregates can be extrapolated, others cannot - we may add the capability to additional aggregates in the future.
91
-
- A lot of care should be taken about how to expose extrapolation and especially switching of the modes to the user.
79
+
- Some aggregates can be extrapolated, others cannot.
80
+
- A lot of care should be taken about how to expose extrapolation in the product, and especially in offering switching modes to a user.
Copy file name to clipboardExpand all lines: develop-docs/sdk/expected-features/rate-limiting.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,7 @@ While these [data categories](https://github.com/getsentry/relay/blob/master/rel
97
97
-`profile_chunk`: Continuous Profiling chunks
98
98
-`replay`: Session Replays
99
99
-`feedback`: User Feedbacks
100
-
-`metric_bucket`: Sentry Metrics sent via the `statsd` or `metrics` items. The `namespaces` component of the *quota_limit* defines which namespace(s) will be affected.
100
+
-`trace_metric`: Metric type events
101
101
-`internal`: a sentry/system internal event[^internal]
102
102
103
103
-**Scope**: The unit / model in Sentry that quotas are enforced for.
description: "Learn how extrapolation provides accurate metrics from sampled data so you can trust your dashboards and alerts even when you're not capturing every event."
5
+
---
6
+
7
+
When you use [sampling](/concepts/key-terms/sample-rates/) to control the volume of data sent to Sentry, you're only capturing a portion of your app's actual traffic. For example, if you sample 10% of 1000 requests, Sentry receives 100 spans. But how do you easily see the actual traffic and performance metrics for your app?
8
+
9
+
That's where extrapolation comes in. Sentry automatically uses extrapolation to calculate accurate metrics from your sampled data, giving you a realistic view of your application's behavior without requiring you to capture every single event, or do the math yourself.
10
+
11
+
## Why Extrapolation Matters
12
+
13
+
When you sample data, you need a way to understand what the full picture looks like. Extrapolation solves three key problems:
14
+
15
+
-**See real-world numbers**: View metrics that reflect your actual traffic volume, not just the sampled portion. If you sample 10% of 1000 requests, Sentry shows you metrics for all 1000 requests — no mental math required.
16
+
17
+
-**Consistent data when sample rates change**: If you adjust your sample rate from 10% to 1%, your graphs and alerts stay stable. Without extrapolation, you'd see a sudden drop in all your metrics that has nothing to do with actual performance changes.
18
+
19
+
-**Accurate aggregates across different sample rates**: Different parts of your application might have different sample rates. Extrapolation correctly combines data from an endpoint sampled at 1% with another at 100%, giving you accurate percentiles and averages across your entire app.
Every span sent to Sentry includes its sampling rate. Sentry uses this to calculate a **sampling weight** — the number of original spans that each sample represents.
25
+
26
+
For example:
27
+
- At a sampling rate of 10%, the weight is 10
28
+
- At a sampling rate of 50%, the weight is 2
29
+
- At a sampling rate of 100%, the weight is 1
30
+
31
+
When you run queries, Sentry uses these weights to give you accurate counts, averages, and percentiles.
32
+
33
+
### Example
34
+
35
+
Let's say you query for database spans (`span.op:db`) and Sentry returns 2 sampled spans:
Sentry weights the metrics by the sampling rates so you get accurate results that reflect your application's true performance.
51
+
52
+
## What Can Be Extrapolated
53
+
54
+
Most common aggregates can be extrapolated:
55
+
56
+
| Aggregate | Can be extrapolated? |
57
+
| --- | --- |
58
+
| count | Yes |
59
+
| avg | Yes |
60
+
| sum | Yes |
61
+
| percentiles (p50, p75, p90, p95, p99) | Yes |
62
+
| min | No |
63
+
| max | No |
64
+
| count_unique | No |
65
+
66
+
Extreme values like `min` and `max` aren't extrapolated because they're less stable when sampling — a single outlier can have an outsized impact.
67
+
68
+
## When to Turn Off Extrapolation
69
+
70
+
While extrapolation is usually helpful, if you are exclusively looking to confirm your sampling usage or look exclusively at sampled data, you can turn off extrapolation.
71
+
72
+
You can disable extrapolation using the settings icon above charts in tools like Trace Explorer. Note that with extrapolation off, your metrics will only reflect the sampled data, not your full traffic.
73
+
74
+
<Alert>
75
+
If Sentry displays a **low confidence warning**, it means there isn't enough sampled data for reliable extrapolation. Consider increasing your sample rate or widening your query filters.
76
+
</Alert>
77
+
78
+

0 commit comments