Skip to content

feat(opencode): improve telemetry tracing and request spans#22653

Merged
kitlangton merged 8 commits into
devfrom
fix/otel-context-manager
Apr 15, 2026
Merged

feat(opencode): improve telemetry tracing and request spans#22653
kitlangton merged 8 commits into
devfrom
fix/otel-context-manager

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • register the OTel context manager so AI SDK spans flow into the active Effect trace tree
  • add request-level route spans for key session and config read handlers to make lonely getter traces easier to understand
  • simplify the request tracing helper while keeping the generator-style Effect bodies type-safe

Verification

  • verified in Motel that AI SDK spans are emitted and correlated with opencode traces
  • verified route spans like SessionRoutes.get and SessionRoutes.todo appear as parents of Session.get / Todo.get
  • workspace typecheck passed during commit

Notes

  • local uncommitted changes in packages/opencode/src/session/prompt.ts are intentionally not included in this PR

… traces

@effect/opentelemetry creates a NodeTracerProvider but never calls
register(), leaving the global @opentelemetry/api context manager as
the no-op default. The AI SDK calls tracer.startActiveSpan() which
relies on context.active() to find parent spans — without a real
context manager every AI SDK span started a new trace.

Registering AsyncLocalStorageContextManager before the NodeSdk layer
fixes this. Verified with motel: traces went from singleton AI SDK
spans to 400+ spans properly threaded under SessionPrompt.prompt.
@kitlangton kitlangton enabled auto-merge (squash) April 15, 2026 21:30
@kitlangton kitlangton disabled auto-merge April 15, 2026 21:32
@kitlangton kitlangton merged commit 6bed7d4 into dev Apr 15, 2026
8 checks passed
@kitlangton kitlangton deleted the fix/otel-context-manager branch April 15, 2026 21:32
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
dgokeeffe pushed a commit to dgokeeffe/opencode-databricks that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant