fix(otel): use monotonic_counter prefix and support temporality env var#7234
Merged
michaelneale merged 1 commit intomainfrom Feb 16, 2026
Merged
fix(otel): use monotonic_counter prefix and support temporality env var#7234michaelneale merged 1 commit intomainfrom
michaelneale merged 1 commit intomainfrom
Conversation
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical regression where most OTel metrics were accidentally changed from monotonic_counter. to counter. prefix, which broke Prometheus counter functionality (rate() and increase() functions). It also adds environment variable support for configuring metrics temporality preference via OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.
Changes:
- Corrected metric prefix from
counter.back tomonotonic_counter.across all telemetry instrumentation points - Added temporality preference configuration via environment variable with support for delta, cumulative, and lowmemory modes
- Comprehensive parameterized tests for temporality preference parsing
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/goose/src/otel/otlp.rs | Added temporality_preference() function to read ENV var, applied temporality to OTLP metrics exporter, added comprehensive test coverage |
| crates/goose/src/security/mod.rs | Fixed metric prefixes from counter. to monotonic_counter. for security scanner metrics (5 locations) |
| crates/goose/src/agents/tool_execution.rs | Fixed metric prefix for prompt_injection_user_decisions counter |
| crates/goose-server/src/routes/schedule.rs | Fixed metric prefix for recipe_runs counter |
| crates/goose-server/src/routes/reply.rs | Fixed metric prefixes for session and tool metrics (7 locations) |
| crates/goose-cli/src/session/mod.rs | Fixed metric prefixes for tool_calls and tool_completions counters |
| crates/goose-cli/src/cli.rs | Fixed metric prefixes for session and CLI command metrics (7 locations) |
michaelneale
approved these changes
Feb 16, 2026
michaelneale
added a commit
that referenced
this pull request
Feb 17, 2026
* main: fix: handle reasoning_content for Kimi/thinking models (#7252) feat: sandboxing for macos (#7197) fix(otel): use monotonic_counter prefix and support temporality env var (#7234) Streaming markdown (#7233) Improve compaction messages to enable better post-compaction agent behavior (#7259) fix: avoid shell-escaping special characters except quotes (#7242)
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.
Summary
This fixes a regression where most (not all) otel metrics were accidentally changed from
monotonic_counter.tocounter.and adds ENV support for metrics temporality preference.The regression is subtle but made the metrics practically unusable for the things you'd actually want (rates, alerts, per-minute breakdowns).
For example, when monotonic a counter becomes a Prometheus counter, suppporting
rate()andincrease(), allowing you to build dashbaords like "tool calls per minute" or "sessions per hour".Similar to our other ENV, this adds support for
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEThe default temporarilty is
cumulative, which on export sends the total since the process start.Backends who compute deltas internally, like Prometheus, expect this default.
deltaonly sends the delta since the last export, which is needed for backends like Elastic Stack and otel-tui.When this isn't configurable, metrics are counted incorrectly, a total mistaken for a delta. This makes the metrics unusable.
Type of Change
AI Assistance
Testing
temporality_preference_from_envparameterized testsRelated Issues
monotonic_counter.prefix)counter.for all but one metric.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEin the SDK