Skip to content

feat(propagators): honor upstream sampling decisions - #925

Open
CagriYonca wants to merge 1 commit into
mainfrom
feat-sampling-suppression
Open

CagriYonca wants to merge 1 commit into
mainfrom
feat-sampling-suppression

Conversation

@CagriYonca

Copy link
Copy Markdown
Contributor

Problem

Without X-INSTANA-L, the Python tracer ignored the sampled flag of an incoming traceparent. Upstream tracers such as OpenTelemetry that rejected a trace (…-00) still got spans from us. Separately, when a trace was suppressed, BinaryPropagator (gRPC client, ASGI responses) leaked X-INSTANA-T/S and Server-Timing, and TextPropagator always wrote level 1.

What needed to be done

  • Honor the traceparent sampled flag when X-INSTANA-L is absent, as defined in the tracer specification.
  • Add the specified opt-out, disable-w3c-sampled-flag-inheritance.
  • Stop writing X-INSTANA-T/S and Server-Timing for suppressed traces, and keep the real level in TextPropagator.

What was done

  • A traceparent sampled flag of 0 now suppresses tracing when X-INSTANA-L is absent. X-INSTANA-T/S do not affect the level. The incoming parent-id is propagated downstream.
  • New option tracing.global.disable-w3c-sampled-flag-inheritance, default false. Sources: env INSTANA_TRACING_DISABLE_W3C_SAMPLED_FLAG_INHERITANCE, YAML, agent config. When enabled, the flag is ignored, X-INSTANA-L: 1 and …-01 are sent, and th is removed from the outgoing ot tracestate entry.
  • BinaryPropagator and TextPropagator skip X-INSTANA-T/S and Server-Timing when suppressed. TextPropagator writes the real level, and BinaryPropagator writes traceparent even without tracestate.
  • Behavior change: upstreams sending traceparent …-00 without Instana headers are now dropped. The option restores the old behavior.
  • Assumption: the flag is also honored when INSTANA_DISABLE_W3C_TRACE_CORRELATION is set. The spec does not cover this and the question is open in the spec PR.

How it was tested

  • pytest tests/propagators tests/test_options.py tests/util tests/w3c_trace_context: 468 passed.

@CagriYonca CagriYonca self-assigned this Dec 2, 2026
@CagriYonca
CagriYonca requested a review from a team as a code owner December 2, 2026 10:01
@github-actions

This comment was marked as resolved.

@CagriYonca
CagriYonca force-pushed the feat-sampling-suppression branch from 20ee2af to 3bceed1 Compare December 2, 2026 10:06
Signed-off-by: Cagri Yonca <cagri@ibm.com>
@CagriYonca
CagriYonca force-pushed the feat-sampling-suppression branch from 3bceed1 to 42818c2 Compare December 2, 2026 10:07
@pvital pvital added the feature label Dec 2, 2026

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants