|
| 1 | +--- |
| 2 | +title: Extrapolation |
| 3 | +sidebar_order: 80 |
| 4 | +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. |
| 20 | + |
| 21 | +## How Extrapolation Works |
| 22 | + |
| 23 | + |
| 24 | +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: |
| 36 | + |
| 37 | +| span_id | span.op | span.duration | sampling_factor | sampling_weight | |
| 38 | +| --- | --- | --- | --- | --- | |
| 39 | +| a1b2c3 | db | 100ms | 0.1 | 10 | |
| 40 | +| d4e5f6 | db | 200ms | 0.5 | 2 | |
| 41 | + |
| 42 | +Even though you only see 2 spans, extrapolation helps Sentry calculate metrics for all the spans they represent: |
| 43 | + |
| 44 | +**Count**: `10 + 2 = 12` estimated spans |
| 45 | + |
| 46 | +**Sum**: `(10 × 100ms) + (2 × 200ms) = 1,400ms` |
| 47 | + |
| 48 | +**Average**: `(100ms × 10 + 200ms × 2) / (10 + 2) = 117ms` |
| 49 | + |
| 50 | +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, there are times when you'll want to look at the raw sampled data instead: |
| 71 | + |
| 72 | +**Low sample rate and low event volume**: When both are low, extrapolation becomes less reliable. Sentry will show a warning when confidence is low. You can increase your sample rate, widen your time range, or turn off extrapolation to examine actual captured events. |
| 73 | + |
| 74 | +**Debugging specific events**: If you need to investigate a particular user's experience or trace through actual spans, turn off extrapolation to see exactly what was captured. |
| 75 | + |
| 76 | +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. |
| 77 | + |
| 78 | +<Alert> |
| 79 | +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. |
| 80 | +</Alert> |
| 81 | + |
| 82 | + |
| 83 | + |
0 commit comments