feat(telemetry): add OpenTelemetry instrumentation with Aspire Dashboard support#6629
feat(telemetry): add OpenTelemetry instrumentation with Aspire Dashboard support#6629Hona wants to merge 227 commits into
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()
…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)
|
@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? |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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