[HOLD] chore(otel): Migrate from v1 to v2#1844
[HOLD] chore(otel): Migrate from v1 to v2#1844enie123 wants to merge 1 commit intotemporalio:mainfrom
Conversation
|
Thanks a lot for offering this PR. Unfortunately, we can't simply "upgrade" to OTel v2, as that would be a breaking change for all existing Temporal setups. The plan is therefore to make a new package for this, something like Now, we're going through some heavy work to improve the completeness and DX on the OTel v1 interceptor at the moment. Those improvements will also be applicable to the v2, so much that it makes little sense to create the OTel v2 before we're done with present work on v1. So the path forward will be, in proper order:
In the mean time, you may use your own v2 copy of the OTel interceptors. There's really nothing here that requires that to be part of the official SDK. I'll leave this PR open until then, so that other interested users may benefit from it. |
|
Looks like there's an updated attempt at this in... |
What was changed
This PR migrates the
@temporalio/interceptors-opentelemetrypackage from OpenTelemetry (OTel) v1.x to v2.x.Core Changes:
@opentelemetry/*dependencies to compatible v2 versions.Why?
Migration to OpenTelemetry V2
This PR uses
BasicTracerProviderand avoids usingNodeTracerProvider: #1741The Reasoning:(LLM)
windowandperformance). It explicitly removes Node.js globals likeprocessand restricts access to native modules.NodeTracerProviderattempts to loadasync_hooks(a native Node module) to manage context. Since the sandbox blocks native modules, usingNodeTracerProviderwill cause the workflow to crash or behave non-deterministically. We must useBasicTracerProviderwhich is platform-agnostic.BasicTracerProviderimplicitly registered environment-based propagators. In OTel V2, this side effect was removed. As a result, trace context propagation was failing (generating fragmented traces forStartWorkflow->RunWorkflow->RunActivity).otel.propagation.setGlobalPropagator(new W3CTraceContextPropagator())to manually restore the behavior required for the Sandbox to extract/inject headers correctly.Checklist
Closes: [Feature Request] Add support for opentelemetry v2 #1658
How was this tested:
pnpm test