dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Feature Request: OpenTelemetry: Support Baggage in OtelContext

Open Xyaren opened this issue 2 years ago • 3 comments

Currently when OtelContext.with or OtelContext.get is called with context key opentelemetry-baggage-key (defined in io.opentelemetry.api.baggage.BaggageContextKey#KEY) null is returned.

Setup: Java agent running with DD_TRACE_OTEL_ENABLED=true

This key seems to be used by otel to set or get an instance of io.opentelemetry.api.baggage.Baggage. In order to be able to use baggage with open-telemetry this context key needs to be handled.

Xyaren avatar Oct 23 '23 17:10 Xyaren

Hello @Xyaren 👋

Thanks for reaching us.

We currently don't support baggage with our OTel instrumentation. It is mainly due to the lack of support for the Context lifecycle. So even if you were able to store baggage, you won't retrieve any meaningful value when needed.

It is identified as a compatibility issue on our OTel support roadmap though. We really appreciate if you can open a feature request on our support page so we can make sure to keep track of it, and our support team will be able to learn more about you and your context. Don't hesitate to link this issue as reference.

Best, Bruce

PerfectSlayer avatar Oct 27 '23 14:10 PerfectSlayer

Hello, is there a link to the OTEL Support Roadmap you mentioned?

Best Regeards, Tobias

Xyaren avatar Jan 23 '25 15:01 Xyaren

Any news ? I saw a few changes around baggage handling

Xyaren avatar Jun 20 '25 08:06 Xyaren

Is this on any roadmap? It is such an essential feature when it comes to propagating information in a large scale microservice network...

pontus-eliason avatar Oct 21 '25 13:10 pontus-eliason

@PerfectSlayer Since you support Baggage now with https://github.com/DataDog/dd-trace-java/pull/9289 could you have another look please ?

Xyaren avatar Nov 05 '25 13:11 Xyaren

Current status - the following use cases are supported in 1.47.0 and later:

  • manually using the OTel API to set/get baggage in the same JVM
  • automatic propagation of baggage from upstream services to downstream services

The remaining gap is being able to manually use the OTel API to affect the automatic baggage propagation. This requires some additional work in how we map and manage baggage context keys, like we do for the span context keys.

I'll update this issue once the remaining gap is closed.

mcculls avatar Nov 06 '25 10:11 mcculls

The remaining gap should be addressed by the following PRs:

  • https://github.com/DataDog/dd-trace-java/pull/9982
  • https://github.com/DataDog/dd-trace-java/pull/9987

These PRs will ship in the v1.56.0 release

mcculls avatar Nov 17 '25 19:11 mcculls

:robot: This issue has been addressed in the latest release. Check full details in the Release Notes.

github-actions[bot] avatar Nov 20 '25 14:11 github-actions[bot]