[opencode-observability-plugin] Add opt-in W3C trace context propagation #19534
Replies: 2 comments
|
The screenshots make the case well — and from the Langfuse side the mechanism you're relying on is fully supported, which is worth stating explicitly for the maintainers: Langfuse natively ingests OTLP ( Two things worth carrying into the plugin README if this ships:
On the V2 limitation: documenting it as unsupported until the transport preserves supplied parent context (vs. overwriting on the wire) is the right call — a The |
|
I've submitted PR #60 implementing opt-in W3C trace context propagation for both OpenCode V1 and V2. The implementation has been tested end-to-end with OpenCode V1 and V2, AgentGateway, and Langfuse. V2 requires the corresponding OpenCode transport fix: anomalyco/opencode#61386. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature or potential improvement
Feature
OpenCode and OpenTelemetry-enabled LLM gateways currently create separate traces. Tested on agentgateway 1.6.0, Langfuse 4.71.0 and Opencode 1.19.5 and Opencode 2.2.4
Without feature:

Add an optional
LANGFUSE_PROPAGATE_TRACE_CONTEXT=truesetting so outbound LLM requests can carry the existing Langfuse trace context. It must be disabled by default, preserve existingtraceparentheaders, and never create a new Trace ID only for propagation.Proposed Solution
Use OpenCode 1's
chat.headershook to inject W3Ctraceparent, preferring the active generation span and falling back to the current turn.Validate span context, preserve existing headers, and add tests for formatting, hierarchy, missing context, concurrency, and plugin replacement.
Support OpenCode 2 only after its native transport can preserve or adopt the supplied parent context. Until then, document V2 as unsupported rather than injecting a header that is overwritten on the wire. More detail is in my comment here: anomalyco/opencode#49038
Solution ready
I have working solution based on last version of https://github.com/langfuse/opencode-observability-plugin - 0.7.0. It is working with agentgateway 1.6.0, Langfuse 4.71.0 and Opencode 1.19.5 and Opencode 2.2.4 (just with "fixed" OpenCode itself)
With feature:

Additional information
No response
All reactions