Skip to content

fix: overwrite DSC sample_rate when sampling #4392

@Flash0ver

Description

@Flash0ver

Description

Overwrite Dynamic Sampling Context (DSC) sample_rate when sampling decision is made

See: https://linear.app/getsentry/project/update-the-dscs-sample-rate-e4e8398e6acc/overview
See also: getsentry/team-sdks#117

Description

As required by Relay and the EAP, the sample_rate in the DSC must specify the actual sample rate of the trace. If an SDK overrides the sample rate of an incoming trace, for example by invoking the tracesSampler, the new rate must be set on the DSC.
Note that usually the DSC is supposed to be immutable, which includes the sample rate, to ensure complete traces. Invoking the tracesSampler purposefully opts out of this and modifies the DSC.

Implementation

On an incoming trace, the DSC's sample_rate is updated if:

  • an explicit sampling decision is forced, e.g. startTransaction(sampled: true)
  • the tracesSampler is invoked
  • the tracesSampleRate is used
  • the SDK downsamples due to backpressure

Symptom

The Trace-View's extrapolation is based on the "sample_rate" of the Dynamic Sampling Context.
So it needs to reflect the actual "sample_rate" used, when the downstream SDK makes a sampling decision.

Metadata

Metadata

Assignees

Labels

.NETPull requests that update .net codeBugSomething isn't working

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions