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/dynamic-sampling/extrapolation.mdx
+21-23Lines changed: 21 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,34 +3,22 @@ title: Extrapolation
3
3
sidebar_order: 5
4
4
---
5
5
6
-
Sentry’s system uses sampling to reduce the amount of data ingested, for reasons of both performance and cost. This means that when configured, Sentry only ingests a fraction of the data 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. Of course, without making up for the sample rate, this misrepresents the true volume of an application, and when different parts of the application have different sample rates, there is even an unfair bias, skewing the total volume towards parts with higher sample rates. This effect is exacerbated for numerical attributes like latency.
6
+
Sentry’s system uses sampling to reduce the amount of data ingested, for reasons of both performance and cost. When configured, Sentry only ingests a fraction of the data 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. Of course, without making up for the sample rate, any metrics attached to 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 effect is exacerbated for numerical attributes like latency, whose accuracy will be negatively affected by such a bias.To account for this fact, Sentry uses extrapolation to smartly combine the data to account for sample rates.
7
7
8
-
To account for this fact, Sentry uses extrapolation to smartly combine the data that was ingested to account for sample rates in the application. However, low sample rates will cause the extrapolated data to be less accurate than if there was no sampling at all and the application was sampled at 100%.
9
-
10
-
So how does one handle this type of data, and when is extrapolated data accurate and expressive? Let’s start with some definitions:
8
+
So 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:
11
9
12
10
-**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.
13
11
-**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.
14
12
15
13
Data can be any combination of accurate and expressive. To illustrate these properties, let's look at some examples. A single sample with specific tags and a full trace can be very expressive, and a large amount of spans can have very misleading characteristics that are not very expressive. When traffic is low and 100% of data is sampled, the system is fully accurate despite aggregates being affected by inherent statistical uncertainty that reduce expressiveness.
16
14
17
-
At first glance, extrapolation may seem unnecessarily complicated. However, for high-volume organizations, sampling is a way to control costs and egress volume, and 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 to the user:
15
+
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 to the user:
18
16
19
-
-**Steady data when the sample rate changes**: 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, suddenly you have a drop in all associated metrics. Extrapolation corrects for this, so your graphs are steady, and your alerts don’t fire on a change of sample rate.
17
+
-**Steady data 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.
20
18
-**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?
21
19
22
-
### **Modes**
23
-
24
-
There are two modes that can be used to view data in Sentry: default mode and sample mode.
25
-
26
-
- Default mode extrapolates the ingested data as outlined below.
27
-
- Sample mode does not extrapolate and presents exactly the data that was ingested.
28
-
29
-
Depending on the context and the use case, one mode may be more useful than the other.
30
-
31
-
Generally, default mose 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 may be scenarios where the user will want to switch between modes, for example to examine the aggregate numbers first, and dive into single samples for investigation, therefore the extrapolation mode setting should be a transient view option that resets to default mode when the user opens the page the next time.
32
-
33
-
## Aggregates
20
+
## How does extrapolation work?
21
+
### Aggregates
34
22
35
23
Sentry allows the user to aggregate data in different ways - the following aggregates are generally available, along with whether they are extrapolatable or not:
36
24
@@ -44,7 +32,10 @@ Sentry allows the user to aggregate data in different ways - the following aggre
44
32
| percentiles | yes |
45
33
| count_unique | no |
46
34
47
-
Each of these aggregates has their 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. To extrapolate, the sampling weights have to be used in the following ways:
35
+
Each of these aggregates has their 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.
36
+
37
+
### Extrapolation for different aggregates
38
+
To extrapolate, the sampling weights have to be used in the following ways:
48
39
49
40
-**Count**: Calculate a sum of the sampling weight
50
41
Example: the query `count()` becomes `round(sum(sampling weight))`.
-**Percentiles**: Use `*TDigestWeighted` with `sampling_weight_2`.
56
47
We use the integer weight column since weighted functions in Clickhouse do not support floating point weights. Furthermore, performance and accuracy tests have shown that the t-digest function provides best runtime performance (see Resources below).
57
48
Example: the query `quantile(0.95)(foo)` becomes `quantileTDigestWeighted(0.95)(foo, sampling_weight_2)`.
58
-
-**Max / Min**: No extrapolation.
59
-
There will be investigation into possible extrapolation for these values.
60
-
61
-
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 fluctation of 100.000 via the noise introduced by a sample rate of 0.00001 is not as salient.
62
49
50
+
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 fluctation of 100.000 via the noise introduced by a sample rate of 0.00001 is not as critical.
63
51
64
52
## How to deal with extrapolation in the product?
53
+
### **Modes**
54
+
55
+
There are two modes that can be used to view data in Sentry: default mode and sample mode.
56
+
57
+
- Default mode extrapolates the ingested data as outlined below.
58
+
- Sample mode does not extrapolate and presents exactly the data that was ingested.
59
+
60
+
Depending on the context and the use case, one mode may be more useful than the other.
61
+
62
+
Generally, default mose 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 may be scenarios where the user will want to switch between modes, for example to examine the aggregate numbers first, and dive into single samples for investigation, therefore the extrapolation mode setting should be a transient view option that resets to default mode when the user opens the page the next time.
0 commit comments