Skip to content

ref: Add support for custom sampling context to span first (14)#5628

Merged
sentrivana merged 96 commits into
masterfrom
ivana/span-first-14-custom-sampling-context
Mar 11, 2026
Merged

ref: Add support for custom sampling context to span first (14)#5628
sentrivana merged 96 commits into
masterfrom
ivana/span-first-14-custom-sampling-context

Merge branch 'master' into ivana/span-first-14-custom-sampling-context

7403dd2
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
GitHub Actions / warden: code-review completed Mar 11, 2026 in 3m 25s

1 issue

code-review: Found 1 issue (1 medium)

Medium

Custom sampling context can overwrite span data via key collision - `sentry_sdk/tracing_utils.py:1434`

The sampling_context.update(propagation_context.custom_sampling_context) call at line 1434 allows user-provided custom sampling context to overwrite the span key. If a user calls scope.set_custom_sampling_context({"span": {...}}), it would replace the span metadata populated at lines 1423-1430, causing the traces_sampler to receive incorrect or missing span information.


Duration: 3m 23s · Tokens: 1.2M in / 13.8k out · Cost: $1.55 (+extraction: $0.00, +fix_gate: $0.00)

Annotations

Check warning on line 1434 in sentry_sdk/tracing_utils.py

See this annotation in the file changed.

@github-actions github-actions / warden: code-review

Custom sampling context can overwrite span data via key collision

The `sampling_context.update(propagation_context.custom_sampling_context)` call at line 1434 allows user-provided custom sampling context to overwrite the `span` key. If a user calls `scope.set_custom_sampling_context({"span": {...}})`, it would replace the span metadata populated at lines 1423-1430, causing the traces_sampler to receive incorrect or missing span information.