Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
When OpenCode spawns tool subprocesses (shell tool, stdio MCP transports, LSP servers, formatter, git, etc.), it does not propagate the active OTel context. Tools that emit their own telemetry land in disconnected root traces, breaking continuity between the OpenCode invocation and the work the tool performed.
Expected behavior
When OpenCode spawns a tool subprocess, the OTel context active at spawn time should be propagated via the standard TRACEPARENT (and TRACESTATE when non-empty) env vars, per the OTel environment variable carrier spec. Tool subprocesses that emit OTel-instrumented telemetry should appear as children of opencode's invocation trace.
Scope
Every subprocess spawn site:
- Shell tool (
packages/opencode/src/tool/shell.ts)
- Stdio MCP transports (
packages/opencode/src/mcp/index.ts → StdioClientTransport)
- All Effect-based
spawner.spawn callers (LSP servers, git/worktree, format, snapshot, project, etc.) — these route through packages/core/src/cross-spawn-spawner.ts, so a single injection point there covers them all.
Related
Sibling to #18801, which covers the inbound direction (extracting traceparent from incoming HTTP requests). Together they close the loop on trace context propagation across opencode's process boundaries
Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
When OpenCode spawns tool subprocesses (shell tool, stdio MCP transports, LSP servers, formatter, git, etc.), it does not propagate the active OTel context. Tools that emit their own telemetry land in disconnected root traces, breaking continuity between the OpenCode invocation and the work the tool performed.
Expected behavior
When OpenCode spawns a tool subprocess, the OTel context active at spawn time should be propagated via the standard
TRACEPARENT(andTRACESTATEwhen non-empty) env vars, per the OTel environment variable carrier spec. Tool subprocesses that emit OTel-instrumented telemetry should appear as children of opencode's invocation trace.Scope
Every subprocess spawn site:
packages/opencode/src/tool/shell.ts)packages/opencode/src/mcp/index.ts→StdioClientTransport)spawner.spawncallers (LSP servers, git/worktree, format, snapshot, project, etc.) — these route throughpackages/core/src/cross-spawn-spawner.ts, so a single injection point there covers them all.Related
Sibling to #18801, which covers the inbound direction (extracting
traceparentfrom incoming HTTP requests). Together they close the loop on trace context propagation across opencode's process boundaries