temporal-opentelemetry: Native OpenTelemetry Usage
Overview#
Currently, Temporal Java SDK users who need OpenTelemetry integration must rely on the temporal-opentracing module with an OpenTelemetry compatibility layer (https://github.com/open-telemetry/opentelemetry-java/tree/main/opentracing-shim).
There are documented considerations in the https://opentelemetry.io/docs/specs/otel/compatibility/opentracing/#when-to-use, particularly with baggage propagation, as it specifically warns: "The related Baggage may not be properly propagated if the OpenTelemetry API is consumed along the OpenTracing Shim."
The documentation explicitly recommends against using the shim when: "consuming both OpenTracing Shim and OpenTelemetry API in the same codebase," which is precisely the scenario I am facing while trying to use OpenTelemetry Baggage Span Processor.
As OpenTracing is in maintenance mode and OpenTelemetry is the industry standard (https://www.cncf.io/projects/opentelemetry/), a native implementation would provide the recommended path forward for reliable, feature-complete tracing in Temporal workflows.
Solution#
I would like to contribute with a new temporal-opentelemetry module that provides native OpenTelemetry integration for the Temporal Java SDK. This module:
- Offers direct OpenTelemetry integration without requiring compatibility shims
- Provides full W3C TraceContext compatibility
- Integrates seamlessly with the broader OpenTelemetry ecosystem
The module will be similar to opentracing but using native opentelemetry API components
Alternatives#
- Continuing to use temporal-opentracing with the OpenTelemetry compatibility layer, but add new SpanProcessor to capture the baggage data but not using the recommend approach
- Create custom temporal interceptors in order to create out own traces and span using open-telemetry directly
Additional context#
This implementation parallels the structure of the temporal-opentracing module, making it easy for users to migrate to use native opentelemetry instrumentation without configure a shim/bridge. It provides a cleaner, more efficient way to integrate Temporal with OpenTelemetry observability stacks.
