ref: Add sampling to span first (11) #5617
1 issue
find-bugs: Found 1 issue (1 medium)
Medium
NoOpStreamedSpan ignores `active` parameter, incorrectly setting itself as scope's active span - `sentry_sdk/scope.py:1212-1216`
When sampled is False, NoOpStreamedSpan is created with scope=self (line 1214) but without passing the active parameter. The NoOpStreamedSpan._start() method unconditionally sets itself as the scope's active span if a scope is provided, ignoring whether active=False was requested by the caller. This causes incorrect span parenting behavior: spans started after a NoOpStreamedSpan with active=False will incorrectly become its children instead of being parented to the previous active span.
Duration: 2m 50s · Tokens: 2.0M in / 16.5k out · Cost: $2.83 (+extraction: $0.00, +fix_gate: $0.00)
Annotations
Check warning on line 1216 in sentry_sdk/scope.py
github-actions / warden: find-bugs
NoOpStreamedSpan ignores `active` parameter, incorrectly setting itself as scope's active span
When `sampled is False`, `NoOpStreamedSpan` is created with `scope=self` (line 1214) but without passing the `active` parameter. The `NoOpStreamedSpan._start()` method unconditionally sets itself as the scope's active span if a scope is provided, ignoring whether `active=False` was requested by the caller. This causes incorrect span parenting behavior: spans started after a NoOpStreamedSpan with `active=False` will incorrectly become its children instead of being parented to the previous active span.