Skip to content

[FEATURE]: propagate outgoing trace context to spawned tool subprocesses #27031

@jlguerreiro

Description

@jlguerreiro

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request 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.tsStdioClientTransport)
  • 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions