Skip to content

Commit 98c18a8

Browse files
committed
incorporate review coments
1 parent 12bd394 commit 98c18a8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

develop-docs/application-architecture/dynamic-sampling/extrapolation.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Extrapolation
33
sidebar_order: 5
44
---
55

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. 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.
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. 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.
77

88
### Accuracy & Expressiveness
99
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:
@@ -16,10 +16,12 @@ Data can be any combination of accurate and expressive. To illustrate these prop
1616
### Benefits of Extrapolation
1717
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:
1818

19+
- **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 on the real behavior without additional knowledge or math required on your end.
20+
1921
- **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.
2022
- **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?
2123

22-
## How does extrapolation work?
24+
## How Does Extrapolation Work?
2325
### Aggregates
2426

2527
Sentry allows the user to aggregate data in different ways - the following aggregates are generally available, along with whether they are extrapolatable or not:
@@ -37,16 +39,16 @@ Sentry allows the user to aggregate data in different ways - the following aggre
3739
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.
3840

3941
### Extrapolation for different aggregates
40-
To extrapolate, sampling weights are calculated as 1/(sample rate). The sampling weights then are used in the following ways:
42+
To extrapolate, sampling weights are calculated as `1/sample rate`. The sampling weights of each row are then used in the following ways:
4143

4244
- **Count**: Calculate a sum of the sampling weight
43-
Example: the query `count()` becomes `round(sum(sampling weight))`.
44-
- **Sum**: Multiply each value with `sampling weight`.
45-
Example: the query `sum(foo)` becomes `sum(foo * sampling weight)`
45+
Example: the query `count()` becomes `round(sum(sampling_weight))`.
46+
- **Sum**: Multiply each value with `sampling_weight`.
47+
Example: the query `sum(foo)` becomes `sum(foo * sampling_weight)`
4648
- **Average**: Calculate the weighted average with sampling weight.
47-
Example: the query `avg(foo)` becomes `avgWeighted(foo, sampling weight)`
49+
Example: the query `avg(foo)` becomes `avgWeighted(foo, sampling_weight)`
4850
- **Percentiles**: Calculate the weighted percentiles with sampling weight.
49-
Example: the query `quantile(0.95)(foo)` becomes `weightedPercentile(0.95)(foo, sampling weight)`.
51+
Example: the query `quantile(0.95)(foo)` becomes `weightedPercentile(0.95)(foo, sampling_weight)`.
5052

5153
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.
5254

@@ -60,9 +62,9 @@ There are two modes that can be used to view data in Sentry: default mode and sa
6062

6163
Depending on the context and the use case, one mode may be more useful than the other.
6264

63-
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.
65+
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 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.
6466

65-
### General approach
67+
### General Approach
6668

6769
In new product surfaces, the question of whether or not to use extrapolated vs non-extrapolated data is a delicate one, and it needs to be deliberated with care. In the end, it’s a judgement call on the person implementing the feature, but these questions may be a guide on the way to a decision:
6870

0 commit comments

Comments
 (0)