Uh oh!
There was an error while loading. Please reload this page.
feat: integrate OpenTelemetry - #5245
Conversation
- Updated bun.lock and package.json to include OpenTelemetry dependencies. - Implemented tracing in various components including session management and tool execution. - Enhanced error handling and event logging for better observability.
rekram1-node
commented
Dec 8, 2025
I think opencode already emits telemetry spans if you set: experimental_opentelemetry to true in your opencode.json |
…lemetry - Moved Tracing initialization to occur before the root CLI span is created. - Wrapped CLI parsing in a span to include command-line arguments in telemetry.
Thanks for the quick response @rekram1-node. I set the following and it didn't work: //.opencode/opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"experimental": {
"openTelemetry": true
},
}I had to modify the repo to get it to emit open telemetry. |
franroa
commented
Jan 3, 2026
Would be nice to have something like this https://www.reddit.com/r/ClaudeCode/comments/1pjon1r/til_that_claude_code_has_opentelemetry_metrics/ |
didier-durand
commented
Jan 6, 2026
Hi, doesn't work for me either. Minimally, additional packages from OpenTelemetry JavaScript SDK need to be added |
pai4451
commented
Jan 13, 2026
I love this feature, is it possible to add open telemetry support and contains productivity metrics (such as acceptance rate or lines of code) like claude code? https://code.claude.com/docs/en/monitoring-usage#lines-of-code-counter |
didier-durand
commented
Jan 13, 2026
Working on a PR to fully enable OTEL for opencode in a container image. Hope to be able to share it soon |
If it helps. I submitted a merge request to add otel support awhile back, but it got very little traction: |
didier-durand
commented
Jan 17, 2026
@Phantal : Yes, I saw your PR. On my side, I am trying to obtain full leverage of AI SDK Otel implementation by Vercel. I want to add much less code than your PR and just minimally change the current Otel setup. |
f1ae801 to
08fa7f7Comparefiktor
commented
Feb 10, 2026
Let me document how OTel in OpenCode works without this PR. I tested the current OpenCode (opencode-ai@1.1.51, opencode-ai@1.1.53, without this PR), and the spans are emitted/exported subject to the following pre-requisites:
Here:
There are 3 types (i.e. 3 values of span.name) logged: ai.streamText, ai.toolCall, ai.streamText.doStream. The spans are not coming directly from OpenCode but from Vercel AI SDK opencode is using. They contain full text of prompts. Here is one of 3 lines where span is created: https://github.com/vercel/ai/blob/c36a873ce00892a4c587c2e9492220b392aefd09/packages/ai/src/generate-text/stream-text.ts#L1142 |
strangemonad
commented
Mar 23, 2026
@rekram1-node This isn't quite true since there's never a span collector set up (e.g. see #6629 and https://github.com/DEVtheOPS/opencode-plugin-otel) A quick search of otel shows many PRs and issues |
paraddise
commented
May 13, 2026
Should we use custom opencode plugins?
or wait native implementation? Because plugins don't have such support as opencode has and we need some guaranties that attributes names won't change in the near future because many commands need to write alerts and parsers of this traces. |
shloimy-wiesel
commented
May 27, 2026
+1 |
rekram1-node
commented
May 27, 2026
opencode has native opentelemetry, set these: |
strangemonad
commented
Jun 10, 2026
@rekram1-node I think you need to also still set the following too? ie the OTEL_EXPORTER_ vars enable the trace exporting and experimental.openTelemetry = true enables the ai-sdk span features? |
sir3mat
commented
Jul 13, 2026
Any update? |
Hi @thdxr, @adamdotdevin, and @rekram1-node
I love opencode. Trying to run it with open telemetry and wanted to add back some code to the project. If you generaly like this commit, I can work on resolving the merge conflict (just imports, nothing big).
Summary
Changes