feat(telemetry): add OpenTelemetry instrumentation with Aspire Dashboard support#6629
Draft
Hona wants to merge 227 commits intoanomalyco:devfrom
Draft
feat(telemetry): add OpenTelemetry instrumentation with Aspire Dashboard support#6629Hona wants to merge 227 commits intoanomalyco:devfrom
Hona wants to merge 227 commits intoanomalyco:devfrom
Conversation
…andard attribute names
…r gRPC trace export
Change experimental.openTelemetry config from boolean to union type supporting both boolean and object with enabled/endpoint fields. This allows users to configure custom OTLP endpoints for Aspire Dashboard integration while maintaining backward compatibility with boolean config.
…tion Add telemetry module with: - Config interface and resolveConfig() for endpoint resolution - init() function with NodeSDK, LoggerProvider, trace/log exporters - shutdown() for graceful cleanup - withSpan() helper for span creation with error handling - isEnabled(), getTracer(), getLogger() utility functions - SeverityMap for log level mapping
Integrate OpenTelemetry log emission into the Log module. When telemetry is enabled, all log messages (debug/info/warn/error) are emitted to the OTLP endpoint alongside file-based logging. - Lazy-load telemetry module to avoid circular dependency - Guard against recursive calls during module initialization - Emit logs with proper severity levels using Telemetry.SeverityMap
- Initialize telemetry in yargs middleware after Log.init() - Check OTEL_EXPORTER_OTLP_ENDPOINT env var or config.experimental.openTelemetry - Register SIGTERM and SIGINT handlers for graceful shutdown - Call Telemetry.shutdown() in finally block before process.exit()
…m/dev Re-apply all OpenTelemetry instrumentation on top of upstream dev (1205 commits merged). Key instrumentation: - GenAI attributes on LLM spans (gen_ai.system, gen_ai.operation.name, etc.) - Token usage tracking (gen_ai.usage.input_tokens/output_tokens) - Database spans with db.system: sqlite for Aspire Database filter - HTTP spans with METHOD /route naming - Tool execution wrapper spans (tool.execute) - Individual tool spans (read, write, edit, bash, grep, etc.) - MCP, LSP, OAuth, plugin, snapshot spans - Context propagation fix for proper span nesting - Aspire Dashboard launch scripts and MCP config
…in.trigger chat.params, etc.)
…at span via onFinish, include tool parameters
…uild vs gen_ai.chat title)
…pire tool definitions
… noise, fix test type
… icon, GenAI icon)
…already emitted in onFinish)
Contributor
|
@Hona Saw your presentation at aspire conf yesterday! Was quite keen to try out the Aspire Dashboard for aspire. Would this PR be needed to get this to work? And would this work with the final built artefact as opposed to just with the dev environment for opencode? We would mainly be interested in it to help us track down issues with our installations of opencode |
|
I saw the talk too and really want this 😅 are there plans for this to be merged? |
Contributor
Closed
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds experimental OpenTelemetry support for debugging and observability.
What
bun run dev:otelopencode-clivsopencode-serverkey=valuecontext + exception stack tracesEnabling OpenTelemetry
~/.config/opencode/opencode.json:{ "experimental": { "openTelemetry": true } }cd packages/opencode bun run dev:otelThe
OTEL_EXPORTER_OTLP_ENDPOINTenv var controls the endpoint (defaults tohttp://localhost:4317).Images