Skip to content

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

Closed as not planned

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.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

Activity

  1. Necmttn commented on Jun 22, 2026

    @Necmttn

    This is also worth testing as a trace-continuity contract.

    A fixture can start one OpenCode turn, spawn shell plus stdio MCP plus one shared spawner.spawn caller, and assert each child process sees the same TRACEPARENT lineage. Store spawn site, child pid, propagated traceparent, parent span id, and whether the child emitted a linked span. That gives a concrete failure when one subprocess path drops context.

    Generated with ax - https://github.com/Necmttn/ax

  2. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions