Skip to content

fix(dsc): Stop using cross-org DSC data in v2 span normalization#6073

Open
elramen wants to merge 15 commits into
masterfrom
elramen-validate-dsc
Open

fix(dsc): Stop using cross-org DSC data in v2 span normalization#6073
elramen wants to merge 15 commits into
masterfrom
elramen-validate-dsc

Conversation

@elramen

@elramen elramen commented Jun 10, 2026

Copy link
Copy Markdown
Member

Stop using cross-org DSC data in v2 span normalization. Instead, nullify DSC attributes when the DSC/trace comes from a different org.

Reason for nullifying instead of using span attributes like sentry.segment_name: there is no guarantee that all spans in the envelope will have the same value set for these attributes. We could check if the spans all align but this is not good because how an SDK groups spans per envelope (e.g. 1 vs 2 segments per envelope) should not impact dynamic sampling.

This change also includes two other improvements:

  1. Put project_id directly in the DSC, removing the need for the EnrichedDsc struct.
  2. Add dsc_mut to EnvelopeHeaders to avoid having to clone and set the DSC when updating only a single attribute.

Fixes RELAY-254

@elramen elramen marked this pull request as ready for review June 10, 2026 16:55
@elramen elramen requested a review from a team as a code owner June 10, 2026 16:55
Comment thread relay-server/src/processing/utils/dynamic_sampling.rs
Comment thread relay-server/src/processing/utils/dsc.rs Outdated
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

RELAY-254

Comment thread relay-sampling/src/dsc.rs Outdated
Comment thread relay-server/src/processing/spans/mod.rs
/// An exception exists for our OTeL integration, which currently never sets a dynamic sampling
/// context. In the future we may want to extract a DSC from the OTeL payload to allow dynamic
/// sampling if the necessary attributes are present.
pub fn validate_dsc_presence(spans: &SerializedSpans) -> Result<()> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we keep this function alive to keep the documentation and reasoning comments alive.

It's fine if this becomes a private function and is just called from a "validate_and_set" step. If that's not really possible, we definitely still want to keep the reasoning and comments alive.

@elramen elramen Jun 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to make the comments more to the point and avoid repetition. I'll bring back context that was lost and we can see if something is still missing.

Comment thread relay-server/src/processing/spans/mod.rs Outdated
Comment thread relay-server/src/processing/legacy_spans/process.rs
Comment thread relay-server/src/processing/utils/dsc.rs Outdated
Comment thread relay-server/src/processing/utils/dsc.rs Outdated
Comment thread relay-server/src/processing/utils/dsc.rs Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 21ded61. Configure here.

Comment thread relay-server/src/processing/utils/dsc.rs
Comment thread relay-event-normalization/src/normalize/span/mod.rs
@elramen elramen requested a review from Dav1dde June 11, 2026 11:25
Ok(())
match ctx.sampling_project_info {
None => {
*dsc = DynamicSamplingContext {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible here that spans.headers already has a DSC with more detailed information (release, environment, etc.)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants