feat(otel): respect standard OTel env vars for exporter selection#7144
feat(otel): respect standard OTel env vars for exporter selection#7144codefromthecrypt merged 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates goose’s OpenTelemetry integration to respect standard OTel environment variables for per-signal exporter selection (traces/metrics/logs) with config-file fallback, adds a console exporter for local debugging, and improves provider shutdown behavior.
Changes:
- Added
otel_configmodule to detect OTel signal/exporter configuration via env vars with config fallback. - Reworked OTLP layer initialization to create traces/metrics/logs pipelines independently and support
otlp|console|none. - Updated CLI/server logging to wire the new propagation init + per-signal layer setup and improved shutdown behavior.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/goose/src/tracing/otlp_layer.rs | Refactors OTel layer creation, resource construction, provider lifecycle/shutdown, and adds tests. |
| crates/goose/src/tracing/otel_config.rs | New env/config detection logic for per-signal exporter selection. |
| crates/goose/src/tracing/mod.rs | Wires in otel_config and updates re-exports for new tracing APIs. |
| crates/goose/Cargo.toml | Adds opentelemetry-stdout dependency for console exporting. |
| crates/goose-server/src/logging.rs | Switches to independent per-signal OTel layer setup + propagation init. |
| crates/goose-cli/src/main.rs | Uses is_otlp_initialized() to decide whether to shutdown providers on exit. |
| crates/goose-cli/src/logging.rs | Switches to independent per-signal OTel layer setup + propagation init. |
| Cargo.lock | Locks the new opentelemetry-stdout dependency and transitive deps. |
|
updating to latest otel and the copilot feedback broke http export which is different recently. will pull out of draft when I figure it out. |
alexhancock
left a comment
There was a problem hiding this comment.
OTel seems the way to go to me, and this looks like a great simple start
cbfaac8 to
aeb375f
Compare
|
re-ran all the tests and manual tests and updated screenshots and console output |
| Configure goose to export traces, metrics, and logs to any | ||
| [OpenTelemetry](https://opentelemetry.io/docs/) compatible platform. | ||
| When configured, goose exports telemetry asynchronously and flushes on exit. |
There was a problem hiding this comment.
This PR updates public documentation alongside feature code; if these docs are intended for a future release, they should be separated or otherwise marked so unreleased behavior isn’t documented in published guides.
There was a problem hiding this comment.
this PR contains already released features/functionality?
Support OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER and OTEL_SDK_DISABLED environment variables. Add console exporter for local debugging alongside the existing OTLP exporter. Each signal (traces, metrics, logs) now initializes independently so one failing doesn't block the others. Shutdown properly flushes all three providers instead of sleeping. Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
708917c to
5a9e01c
Compare
|
michaelneale
left a comment
There was a problem hiding this comment.
seems ok and cross checked it with internal deployment that uses it
|
@blackgirlbytes since this updates docs, this needs an approve to merge. mind giving a look? |
|
@codefromthecrypt I gave this a comment a few days ago but think it got missed. My team prefers you remove the docs, and we will add it back later. Just because the functionality wont be immediately available to everyone! thanks |
Signed-off-by: Adrian Cole <adrian@tetrate.io>
|
moved here! #7221 |
|
Note: I removed the hard-coded 10pct sampling in this change. As @michaelneale noticed it might not be obvious which otel ENV do the same. I updated #7221 with an example to set 10pct, and the same style can apply any rate |
* origin/main: (42 commits) fix: use dynamic port for Tetrate auth callback server (#7228) docs: removing LLM Usage admonitions (#7227) feat(otel): respect standard OTel env vars for exporter selection (#7144) fix: fork session (#7219) Bump version numbers for 1.24.0 release (#7214) Move platform extensions into their own folder (#7210) fix: ignore deprecated skills extension (#7139) Add a goosed over HTTP integration test, and test the developer tool PATH (#7178) feat: add onFallbackRequest handler to McpAppRenderer (#7208) feat: add streaming support for Claude Code CLI provider (#6833) fix: The detected filetype is PLAIN_TEXT, but the provided filetype was HTML (#6885) Add prompts (#7212) Add testing instructions for speech to text (#7185) Diagnostic files copying (#7209) fix: allow concurrent tool execution within the same MCP extension (#7202) fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143) Filter Apps page to only show standalone Goose Apps (#6811) opt: use static for Regex (#7205) nit: show dir in title, and less... jank (#7138) feat(gemini-cli): use stream-json output and re-use session (#7118) ...
Summary
Respect standard OpenTelemetry environment variables for per-signal exporter selection (
OTEL_TRACES_EXPORTER,OTEL_METRICS_EXPORTER,OTEL_LOGS_EXPORTER,OTEL_SDK_DISABLED) and signal-specific endpoints (OTEL_EXPORTER_OTLP_{SIGNAL}_ENDPOINT). Supportsotlp,console, andnoneexporter types.otelmodule (crates/goose/src/otel/) — OTel code moves out oftracing/since it covers traces, metrics, and logsotel::otlpexposessignal_exporter(signal)that checks env vars in priority order: SDK disabled → per-signal exporter → signal-specific endpoint → generic endpointinit_otlp_layers(&Config)replaces duplicated setup in CLI and server — creates all signal layers, promotes config to env, and sets propagation in one callpromote_config_to_envtakes&Configinstead of readingConfig::global(), making it testable with temp config filesshutdown_otlp()on graceful shutdown (CLI already did)TraceContextPropagator) only set when at least one OTLP layer initializesType of Change
AI Assistance
Testing
Build the release binary once (used for all tests below):
Console exporter
All three signals (logs, traces, metrics) show the overridden
service.name=mygooseanddeployment.environment=staging:SDK disabled
OTLP exporter with otel-tui
In one terminal, start otel-tui (listens on
localhost:4317gRPC andlocalhost:4318HTTP by default):In another terminal, run goose with the OTLP endpoint:
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 ./target/release/goose run -t "hello"Example screenshots, note the lack of root span is something to fix in another PR and was the case in main:
Related Issues
Extracted from #5151