
To keep OpenTelemetry baggage out of AI provider requests, stop the baggage propagator from running on those calls: set OTEL_PROPAGATORS to tracecontext only, or clear baggage from the context right before you call the model, then prove it with a canary value and a mock destination that asserts the header never arrives.
Baggage is the one OpenTelemetry signal built to leave your process in outbound HTTP headers. That is its job, and it is also the risk. If you put a user ID, tenant name or session token into baggage so downstream services can read it, an instrumented HTTP client will attach it to a request to OpenAI, Anthropic or a gateway just as happily as to your own backend. The OpenTelemetry docs say it plainly: sensitive baggage items can be shared with unintended resources, like third-party APIs.
This guide covers how the leak happens, how to set a policy, how to block it, and how to test that it stays blocked. Nothing here is automatic. No tool filters baggage for you by default, and that includes telemetry.dev. You configure it, then you verify it.
What OpenTelemetry baggage is, and how it differs from trace context and span attributes
OpenTelemetry baggage is a key-value store of contextual information that travels with a request across service boundaries. The docs describe it as contextual information passed between signals, best used for data typically available only at the start of a request that downstream services need later. Think tenant ID, plan tier or a feature flag set at the edge.
Three things get confused, so separate them:
Trace context carries the trace ID, span ID and sampling flag in the
traceparentheader. It holds opaque identifiers only. It tells the next service where it sits in a trace and says nothing about your users.Baggage carries arbitrary key-value pairs you chose, in the
baggageheader. The values are whatever you put there, in plain text.Span attributes are metadata stored on a span and exported to your telemetry backend. They do not travel in request headers.
This point causes most incidents: baggage is a separate store from attributes on spans, metrics, or logs unless you explicitly copy it. Setting baggage does not put anything on a span, and filtering what you copy into spans does nothing to stop the header. Two different paths, two different controls.
How baggage reaches an AI provider request
Baggage reaches a model provider through the baggage HTTP header, added by a propagator that your HTTP instrumentation calls on every outbound request. If the baggage propagator is enabled and a call runs inside a context that holds baggage, the header goes out. The propagator doesn't care about the destination.
The default makes this easy to miss. OTEL_PROPAGATORS defaults to tracecontext,baggage, meaning W3C Trace Context plus W3C Baggage. You did not opt in to baggage propagation, and you still have it.
The path to your model call usually looks like this:
A request handler sets baggage, such as
user.idortenant.id, in the active context.Your code calls the OpenAI or Anthropic SDK, directly or through a gateway, inside that context.
The SDK uses an HTTP client (
fetch,undici,httpx,requests,aiohttp) that your OpenTelemetry HTTP instrumentation has patched.The patched client injects
traceparentandbaggageinto the outgoing headers.
Does the OpenAI SDK send the baggage header to the API? The SDK has no opinion, but the HTTP client underneath it may, if that client is instrumented and the baggage propagator is active. The same goes for the Anthropic SDK, Bedrock, OpenRouter and LiteLLM. Treat every instrumented outbound client as a possible exit for baggage, and check the actual headers instead of assuming.
Decide what may enter baggage: an allowlist of keys and a rule for sensitive values
Decide what goes into baggage before you decide how to block it, because the cheapest leak to fix is the one that never enters the store. Write an allowlist of keys and enforce it in one place.
A workable policy for a small team:
Allowed keys, a short fixed list such as
tenant.tier,feature.flag,request.region. Low-cardinality, non-identifying values.Pseudonymous IDs only, if you need correlation. An internal opaque ID beats an email address, name or token. Never put a secret, credential, API key, session token or prompt text in baggage.
Never use baggage for authorization. Treat inbound baggage as untrusted input, since any caller can send you a
baggageheader.One setter. Wrap
baggage.setBaggagein a helper that rejects keys not on the list. Code review then has one function to watch instead of every call site.
In TypeScript, that helper is a few lines: check the key against a Set, throw or drop on a miss, and only then call the OpenTelemetry API. In Python, write the same wrapper around baggage.set_baggage. Keep the allowlist in a constant that a test can import.
The allowlist limits what can leak. It does not stop propagation. For that, you need the next section.
Keep baggage out of model requests: tracecontext-only propagators, clearing context at the call boundary, and gateway or host exceptions
Three controls work, and they stack. Use at least the first two.
1. Run tracecontext only. Set the propagator list explicitly so baggage is never injected:
export OTEL_PROPAGATORS=tracecontextThis is the broadest fix and the easiest to audit. The trade-off is that baggage stops propagating everywhere, including to your own services. If nothing downstream reads it, you lose nothing. Support for this variable varies by language SDK, so confirm in your own runtime that the baggage header is gone.
2. Clear baggage at the call boundary. If you need baggage between your own services but not at the provider, run the model call in a context with baggage removed. In Python:
from opentelemetry import baggage, context
def call_model(client, **kwargs):
token = context.attach(baggage.clear())
try:
return client.chat.completions.create(**kwargs)
finally:
context.detach(token)In TypeScript, build a clean context and run the call inside it:
import { context, propagation } from "@opentelemetry/api";
const clean = propagation.deleteBaggage(context.active());
await context.with(clean, () => openai.chat.completions.create(params));deleteBaggage returns a context with the baggage removed, and context.with scopes it to that one call. Keep the trace context so the provider call still nests under its parent span.
3. Handle hosts and gateways deliberately. The HTTP instrumentations for requests and httpx accept URL exclusion options, but exclusion typically disables span creation or propagation for the whole request, trace context included. That can sever your trace at the provider hop, so check what your version actually does before relying on it. A gateway you run yourself, such as a LiteLLM proxy, may be one place you want baggage to flow, since it is your infrastructure. A third-party provider endpoint is not. Make that an explicit per-host decision, not a global default.
Whichever you pick, verify at the egress boundary, including retries and redirects, which re-run the instrumented client.
Test it: synthetic canary values and asserting absence at a mock outbound destination
You cannot prove a negative by reading config, so test for absence at the point where the request leaves. The method is a canary plus a mock destination.
Step 1: set a synthetic canary. Put an obviously fake, unique value into baggage, such as canary.user=CANARY-7f3a91-do-not-send. It must be a string that cannot occur in real data, so any appearance is a leak.
Step 2: stand up a mock outbound destination. Run a local HTTP server and point your model client at it by setting the SDK's base URL (the OpenAI and Anthropic SDKs both accept one). Have it record every request header and body it receives.
Step 3: make a real call through the real stack. Use your actual instrumented client with your actual propagator config, inside a context carrying the canary. Do not mock the HTTP layer, or you will skip the instrumentation that adds the header.
Step 4: assert absence. Fail the test if the baggage header exists, or if the canary string appears anywhere in headers or body:
assert "baggage" not in received.headers
assert "CANARY-7f3a91" not in str(received.headers) + received.bodyAlso assert the positive case: traceparent is present. That way you know the test exercised propagation and did not pass because nothing was injected at all.
Run this in CI on every dependency bump. Upgrading an instrumentation package and changing OTEL_PROPAGATORS in a deploy manifest are the two moments leaks quietly return. Repeat the test for each provider path you use, including the gateway path, since each can inject headers differently.
Keep the trace useful without baggage: copy allowed keys to span attributes and view them in telemetry.dev
Blocking baggage at the provider does not cost you debuggability. Span attributes are the right home for the same context, because they go to your telemetry backend over OTLP and never into a request header.
Copy only the allowlisted keys from baggage onto spans. In the OpenTelemetry SDKs, a custom span processor can read the current baggage in on_start and set matching attributes, filtered through the same allowlist constant your setter uses. One list, two uses.
Then the data you wanted, tenant tier or request region, sits on the span where you can filter by it. telemetry.dev is LLM observability built on OpenTelemetry. It traces model calls, tool steps and retrievals and tracks cost, latency, tokens and errors, and it accepts spans from any OTLP/HTTP exporter, so those attributes show up on your traces without extra work. You can slice a slow or failing call by the attributes you chose to export.
Prompt and output capture is a separate control. telemetry.dev lets you turn prompt capture off per environment before storage, and redaction patterns apply but cannot catch all sensitive data. That governs what is stored in your traces, not what your HTTP client sends to a provider. Treat the two as different problems with different fixes.
For more on checking what actually leaves your service, see OpenTelemetry GenAI Prompt Capture: Inspect Before Export and AI API Middleware: Trace App and Provider Boundaries.
FAQ: baggage vs. attributes, propagators, collectors and exporters, and whether OpenTelemetry is free
Short answers to the common questions are in the FAQ below. The one to remember: baggage travels in headers, attributes travel to your backend, and neither is filtered for you unless you build and test that filter.
Prove the header is gone before you ship
Baggage is useful and dangerous for the same reason: it follows the request wherever the request goes. The defaults send it to every instrumented destination, so a model provider is just another stop unless you say otherwise. Allowlist the keys, set tracecontext-only or clear context at the model call, and keep a canary test in CI that fails if the baggage header ever reaches a mock destination. Then copy the allowed keys to span attributes so you keep the context without the exposure. If you want those spans in one place with cost, latency and token data beside them, send your OTLP traces to telemetry.dev. The Free plan is $0 with 30k units (14-day retention), so you can run the canary test and see the attributes land on a real trace today.
Share this article


