Skip to content

fix: opencode run does not emit OTLP traces even with experimental.openTelemetry enabled #13438

Closed as not planned

Description

@bestend

Summary

opencode run does not produce any trace spans in a local OTEL collector, even when experimental.openTelemetry is enabled and OTEL exporter env vars are set.

In the same environment, manual OTLP trace ingestion works, so collector/backend path is healthy.

Environment

  • OpenCode version: 1.1.65
  • OS: macOS (darwin)
  • Local stack: OpenTelemetry Collector (otel/opentelemetry-collector-contrib:0.123.0) + Jaeger (jaegertracing/jaeger:2.4.0)

Reproduction

  1. Enable OpenTelemetry feature in config:
    {
      "$schema": "https://opencode.ai/config.json",
      "experimental": {
        "openTelemetry": true
      }
    }
  2. Start local collector + jaeger (OTLP HTTP on :4318, gRPC on :4317).
  3. Send a manual OTLP trace to collector (POST /v1/traces) as control.
  4. Run opencode with OTEL env:
    • OTEL_TRACES_EXPORTER=otlp
    • OTEL_METRICS_EXPORTER=none
    • OTEL_LOGS_EXPORTER=none
    • OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
    • OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
    • OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
    • OTEL_SERVICE_NAME=opencode-local-smoke
  5. Compare collector trace count and logs before/after.

Observed Result

  • Baseline trace count: 1
  • After manual OTLP control trace: 2 (as expected)
  • After opencode run: still 2 (no new trace)
  • Collector debug logs only show manual services (manual-curl-test, manual-control), no opencode service.
  • Jaeger /api/services also shows only manual test services.

Expected Result

With experimental.openTelemetry=true + OTEL exporter env vars, opencode run should emit spans to OTLP collector.

Additional Notes

Potentially related issues:

This report is specifically about runtime emission behavior: collector path is verified healthy, but opencode spans are not emitted.

Activity

  1. maxkomarychev commented on May 4, 2026

    @maxkomarychev

    Not exactly the what is reported but I noticed that spans from opencode are always emitted as "opencode" - it appears OTEL_SERVICE_NAME has no effect. At least I could not find those traces while they were indeed working.

    Trying to fix it here: #25739

  2. astefanutti commented on May 31, 2026

    @astefanutti

    Root cause identified: process.exit() in the finally block of index.ts kills the process before the BatchSpanProcessor can flush buffered spans. AppRuntime.dispose() is never called, so the OTel SDK's shutdown/flush chain never runs.

    Fix: #30089

  3. github-actions commented on Jul 31, 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