[PR #799] [CLOSED] add otel for perf debugging #9717

Closed
opened 2026-02-16 18:14:02 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/799
Author: @Schniz
Created: 7/9/2025
Status: Closed

Base: devHead: schniz/add-otel-for-tracing


📝 Commits (1)

  • 21a4625 add otel for perf debugging

📊 Changes

23 files changed (+1500 additions, -503 deletions)

View changed files

📝 bun.lock (+330 -0)
📝 packages/opencode/package.json (+5 -0)
📝 packages/opencode/src/cli/cmd/tui.ts (+85 -71)
📝 packages/opencode/src/index.ts (+2 -0)
📝 packages/opencode/src/lsp/client.ts (+135 -132)
📝 packages/opencode/src/mcp/index.ts (+32 -20)
📝 packages/opencode/src/server/server.ts (+3 -0)
packages/opencode/src/telemetry/hono-middleware.ts (+36 -0)
packages/opencode/src/telemetry/index.ts (+30 -0)
packages/opencode/src/telemetry/otel.ts (+195 -0)
📝 packages/tui/cmd/opencode/main.go (+14 -2)
📝 packages/tui/go.mod (+16 -0)
📝 packages/tui/go.sum (+39 -0)
📝 packages/tui/internal/app/app.go (+69 -21)
📝 packages/tui/internal/completions/files.go (+1 -1)
📝 packages/tui/internal/components/chat/message.go (+10 -5)
📝 packages/tui/internal/components/chat/messages.go (+225 -199)
📝 packages/tui/internal/components/dialog/models.go (+4 -4)
📝 packages/tui/internal/components/dialog/session.go (+36 -32)
packages/tui/internal/telemetry/http.go (+36 -0)

...and 3 more files

📄 Description

This branch adds OpenTelemetry (OTEL) instrumentation for performance monitoring and debugging across both the Node.js backend and Go TUI components.

Key changes:

  • Added telemetry infrastructure: New telemetry modules in both packages with OTEL tracing capabilities
  • Performance instrumentation: Spans and measurements added to critical paths like message processing, API calls, and UI operations
  • Refactored timing logic: Replaced custom timing utilities with standardized OTEL spans
  • Cross-language tracing: Coordinated telemetry between Node.js server and Go TUI client

The goal is to provide better observability into performance bottlenecks and user interaction patterns within the opencode application.


The way I'm using it is with Grafana LGTM stack (with my script) but the easiest way is probably otel-desktop-viewer. I think it only supports traces and not logs or metrics which I haven't implemented yet anyway.

An example run would be to do

$ otel-desktop-viewer &
...
$ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 opencode
[tui intensifies]

the going to localhost:8000 and see the traces in action :)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/799 **Author:** [@Schniz](https://github.com/Schniz) **Created:** 7/9/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `schniz/add-otel-for-tracing` --- ### 📝 Commits (1) - [`21a4625`](https://github.com/anomalyco/opencode/commit/21a462570a325fa03c49e29746083734b84d6f15) add otel for perf debugging ### 📊 Changes **23 files changed** (+1500 additions, -503 deletions) <details> <summary>View changed files</summary> 📝 `bun.lock` (+330 -0) 📝 `packages/opencode/package.json` (+5 -0) 📝 `packages/opencode/src/cli/cmd/tui.ts` (+85 -71) 📝 `packages/opencode/src/index.ts` (+2 -0) 📝 `packages/opencode/src/lsp/client.ts` (+135 -132) 📝 `packages/opencode/src/mcp/index.ts` (+32 -20) 📝 `packages/opencode/src/server/server.ts` (+3 -0) ➕ `packages/opencode/src/telemetry/hono-middleware.ts` (+36 -0) ➕ `packages/opencode/src/telemetry/index.ts` (+30 -0) ➕ `packages/opencode/src/telemetry/otel.ts` (+195 -0) 📝 `packages/tui/cmd/opencode/main.go` (+14 -2) 📝 `packages/tui/go.mod` (+16 -0) 📝 `packages/tui/go.sum` (+39 -0) 📝 `packages/tui/internal/app/app.go` (+69 -21) 📝 `packages/tui/internal/completions/files.go` (+1 -1) 📝 `packages/tui/internal/components/chat/message.go` (+10 -5) 📝 `packages/tui/internal/components/chat/messages.go` (+225 -199) 📝 `packages/tui/internal/components/dialog/models.go` (+4 -4) 📝 `packages/tui/internal/components/dialog/session.go` (+36 -32) ➕ `packages/tui/internal/telemetry/http.go` (+36 -0) _...and 3 more files_ </details> ### 📄 Description This branch adds OpenTelemetry (OTEL) instrumentation for performance monitoring and debugging across both the Node.js backend and Go TUI components. **Key changes:** - **Added telemetry infrastructure**: New telemetry modules in both packages with OTEL tracing capabilities - **Performance instrumentation**: Spans and measurements added to critical paths like message processing, API calls, and UI operations - **Refactored timing logic**: Replaced custom timing utilities with standardized OTEL spans - **Cross-language tracing**: Coordinated telemetry between Node.js server and Go TUI client The goal is to provide better observability into performance bottlenecks and user interaction patterns within the opencode application. --- The way I'm using it is with Grafana LGTM stack ([with my script](https://github.com/Schniz/dotfiles/blob/master/bin/otel-stack)) but the easiest way is probably [otel-desktop-viewer](https://github.com/CtrlSpice/otel-desktop-viewer). I think it only supports traces and not logs or metrics which I haven't implemented yet anyway. An example run would be to do ```sh-session $ otel-desktop-viewer & ... $ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 opencode [tui intensifies] ``` the going to localhost:8000 and see the traces in action :) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:02 -05:00
yindo closed this issue 2026-02-16 18:14:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9717