Skip to content

Continued traces propagate sample_rate=1.0 instead of upstream #8182

Closed

Description

@sentry-junior

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.73.0 (behavior present since 2.22.0)

Steps to Reproduce

  1. Init the SDK with only traces_sample_rate set (e.g. 0.5, no traces_sampler).
  2. Continue an incoming trace that was sampled upstream at 1%:
    headers = {
        "sentry-trace": "771a43a4192642f0b136d5159a501700-1234567890abcdef-1",
        "baggage": "sentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rate=0.01,sentry-sample_rand=0.005,sentry-sampled=true,sentry-public_key=abc",
    }
    transaction = sentry_sdk.continue_trace(headers, name="t", op="http.server")
    with sentry_sdk.start_transaction(transaction):
        print(sentry_sdk.get_baggage())
  3. Inspect the outgoing baggage and the envelope trace header of the sent transaction.

Same result with trace_lifecycle="stream".

Expected Result

The incoming DSC is frozen, so sample_rate=0.01 is propagated as is, in both the envelope trace header and outgoing baggage. The DSC spec says the receiving SDK MUST consider the incoming DSC frozen and propagate its values "as is". Other SDKs propagate the incoming sample rate in this scenario.

Actual Result

Both the envelope trace header and outgoing baggage carry sample_rate=1.0:

sentry-trace_id=771a43a4192642f0b136d5159a501700,sentry-sample_rate=1.0,sentry-sample_rand=0.005,sentry-sampled=true,sentry-public_key=abc

When inheriting the parent decision, the SDK sets the transaction's sample rate to float(parent_sampled), i.e. 1.0, and then writes it over sample_rate in the frozen incoming DSC (Scope.start_transaction, and Scope._update_sample_rate for span streaming). This was introduced in #4018 (released in 2.22.0), which changed test_dsc_continuation_of_trace to expect 1.0 instead of the incoming rate.

Why this matters: Relay derives client_sample_rate from the DSC sample_rate, and Sentry uses it to extrapolate counts in the product. Data from any Python service that continues a trace gets weighted as if it were sampled at 100%. In the example above, extrapolated counts for that service end up 100x too low. Because the overwritten baggage is also propagated, every downstream service inherits 1.0 as well.

via @mjq.

--

View Session [Sentry]

Activity

  1. linear-code commented on Nov 3, 2026

    @linear-code
  2. itsrayeedscodespace commented on Nov 3, 2026

    @itsrayeedscodespace

    I can prepare a focused fix that preserves the incoming frozen DSC sample rate when inheriting an upstream sampling decision, while keeping local sampling decisions able to update it. I would cover both transaction sampling and span streaming, including outgoing baggage and envelope trace metadata. Could a maintainer confirm this approach before I start? The contribution guide requires maintainer discussion on the issue before implementation.

  3. self-assigned this
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions