opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: integrate OpenTelemetry

Open tianhuil opened this issue 1 month ago • 4 comments

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

  • Integrate OpenTelemetry for enhanced tracing and monitoring capabilities
  • Add type annotations to execute and toModelOutput methods in SessionPrompt

Changes

  • Added OpenTelemetry dependencies for comprehensive observability
  • Fixed type annotations in SessionPrompt methods for better type safety
  • Updated package lock file with new dependencies

tianhuil avatar Dec 08 '25 15:12 tianhuil

I think opencode already emits telemetry spans if you set:

experimental_opentelemetry to true in your opencode.json

rekram1-node avatar Dec 08 '25 16:12 rekram1-node

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.

tianhuil avatar Dec 08 '25 19:12 tianhuil