ref: Add sampling to span first (11) #5617
2 issues
Medium
Baggage mutability check missing in _update_sample_rate - `sentry_sdk/scope.py:1255`
The _update_sample_rate method modifies baggage.sentry_items["sample_rate"] without checking if the baggage is mutable. According to the Baggage class documentation (lines 608-611 in tracing_utils.py), callers must verify baggage.mutable is True before mutating the object. When a baggage is parsed from an incoming header that already contains sentry items, mutable is set to False. This means in continued traces, the sample rate update would modify an immutable baggage, violating the documented invariant.
NoOpStreamedSpan lacks test coverage for new sampling/client report behavior - `sentry_sdk/traces.py:488-510`
The NoOpStreamedSpan class has been extended with sampling-related functionality (unsampled_reason parameter, client report recording in _end()), but there are no tests covering this new behavior. The existing tests/tracing/test_noop_span.py tests NoOpSpan but not NoOpStreamedSpan. Per the review checklist, every PR should have appropriate test coverage for functional changes.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 2 | 1m 53s | $1.08 |
| find-bugs | 0 | 4m 4s | $3.36 |
| skill-scanner | 0 | 3m 48s | $0.27 |
| security-review | 0 | 3m 16s | $1.06 |
Duration: 13m 2s · Tokens: 4.4M in / 40.5k out · Cost: $5.79 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00, +dedup: $0.01)