Commit 1f3f3eb
authored
fix(sampling): Attribute
### Description
#### Context
If backpressure handling is active, it lowers the effective sample rate.
There are different outcomes for when a span is unsampled due to
`sample_rate` or `backpressure`.
#### Behavior
Before this change, if under backpressure, we'd only report
`backpressure` as the reason for unsampling if the monitor lowered the
effective sample rate to a falsy value. Which only covers a small
portion of unsample decisions made due to backpressure. The rest would
be reported as a generic `sample_rate` drop, potentially leading to
confusing reporting. If someone e.g. has a `traces_sample_rate` of
`1.0`, they might see spans being dropped because of `sample_rate`,
which is hard to justify.
In this PR, we try to do a better job at determining whether
backpressure was actually the reason a span was dropped and emit the
corresponding outcome.
The idea is, for an unsampled span:
- if `sample_rand` would've been higher than the original,
non-backpressure `sample_rate`, the span would've been unsampled
regardless of backpressure handling, so the outcome should be
`sample_rate`
- if `sample_rand` actually would've been lower than the original
`sample_rate` had the `sample_rate` not been lowered, the span would've
been sampled. In that case backpressure handling is the direct cause and
the outcome should be `backpressure`
#### Issues
<!--
* resolves: #1234
* resolves: LIN-1234
-->
#### Reminders
- Please add tests to validate your changes, and lint your code using
`uv run ruff`.
- Add GH Issue ID _&_ Linear ID (if applicable)
- PR title should use [conventional
commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type)
style (`feat:`, `fix:`, `ref:`, `meta:`)
- For external contributors:
[CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md),
[Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord
community](https://discord.gg/Ww9hbqr)backpressure as unsampling reason more accurately (#6445)1 parent 2ce26d1 commit 1f3f3eb
2 files changed
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1577 | 1577 | | |
1578 | 1578 | | |
1579 | 1579 | | |
| 1580 | + | |
1580 | 1581 | | |
1581 | 1582 | | |
1582 | 1583 | | |
1583 | 1584 | | |
1584 | 1585 | | |
1585 | 1586 | | |
1586 | 1587 | | |
| 1588 | + | |
1587 | 1589 | | |
1588 | 1590 | | |
1589 | 1591 | | |
1590 | 1592 | | |
1591 | 1593 | | |
| 1594 | + | |
1592 | 1595 | | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1597 | 1613 | | |
1598 | 1614 | | |
1599 | 1615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
757 | 820 | | |
758 | 821 | | |
759 | 822 | | |
| |||
0 commit comments