Skip to content

fix(spans): Extract client sample rate from DSC for span v2 - #6299

Draft
mjq wants to merge 2 commits into
masterfrom
mjq/client-sample-rate-streaming
Draft

fix(spans): Extract client sample rate from DSC for span v2#6299
mjq wants to merge 2 commits into
masterfrom
mjq/client-sample-rate-streaming

Conversation

@mjq

@mjq mjq commented Aug 10, 2026

Copy link
Copy Markdown
Member

Currently span v2 (span streaming) spans are missing sentry.client_sample_rate attributes. This value is used by Sentry to set the EAP trace item's client_sample_rate, which is used in EAP's extrapolation. This defaults all streaming spans to a client sample rate of 1.0, meaning extrapolation is frequently incorrect.

If the client sample rate is missing from attributes, try to extract it from the DSC. For consistency, default it to 1.0 here if it's missing from both places.

Even though SDKs aren't expected to set sentry.client_sample_rate, checking for an existing attribute value first means we can e.g. set it during the OTel -> Sentry span conversion (another case we're currently missing).

Fixes RELAY-275.

@linear-code

linear-code Bot commented Aug 10, 2026

Copy link
Copy Markdown

RELAY-275

fn inject_server_sample_rate(
/// Injects the client sample rate attribute into a span. Priority order:
/// attribute, DSC, 1.0 (default).
fn inject_client_sample_rate(attributes: &mut Annotated<Attributes>, dsc_sample_rate: Option<f64>) {

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.

We have a normalization step to normalize the client sample rate, this runs after that normalization, basically bypassing it. I guess a better place would be to just extend the sample rate normalization to create it from the DSC if it doesn't already exist?

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.

Gotcha. Makes sense, I'll move it.

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.

@Dav1dde Two wrinkles that come from moving it:

  1. It ends up happening on every Relay and not just processing Relays. That means the first Relay in the chain will extract from DSC, and after that it'll be indistinguishable from a client setting it - we lose control of applying the logic (outdated customer relays will keep applying the old logic, unlike if we only did this during processing).
  2. This happens before trimming:
    a. We're using up space budget/potentially causing more trimming of user data
    b. Scarier, this attribute itself is subject to trimming

None of that applies to its current spot. Any thoughts/concerns about these?

@mjq
mjq force-pushed the mjq/client-sample-rate-streaming branch from d9b193d to cfc12a5 Compare August 11, 2026 18:18
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.

2 participants