{{ message }}
fix: label unpriced token usage metric by provider name and type - #28210
Merged
Conversation
Contributor
ssncferreira
force-pushed
the
ssncf/unpriced-metric-provider-label
branch
from
August 17, 2026 12:14
0c948bd to
230e766
Compare
ssncferreira
marked this pull request as ready for review
August 17, 2026 12:22
johnstcn
approved these changes
Aug 17, 2026
mtojek
pushed a commit
that referenced
this pull request
Aug 17, 2026
) (#28212) Backport of #28210 Original PR: #28210 - fix: label unpriced token usage metric by provider name and type Merge commit: 95328f1 Requested by: @ssncferreira
ssncferreira
added a commit
that referenced
this pull request
Aug 18, 2026
…#28220) The cardinality notes in `aibridge/metrics/metrics.go` assume the `provider` label takes one of three values, and two for the key pool metrics. That was accurate when the notes were written: `provider` is the provider instance name, and the name defaulted to one of the three provider types aibridge supports. Instances can now be given their own names, so the label takes any configured name and the series counts scale with the number of configured providers rather than being capped at a fixed number. The monitoring docs are also updated to make clear that `provider` is the provider instance name. Comments and documentation only, no behaviour change. Follow-up to #28210.
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.


Problem
The
providerlabel was inconsistent between AI Gateway metrics. Every metric emitted by the gateway labelsproviderwith the provider instance name, for exampleanthropic-eu, whilecoder_ai_gateway_cost_control_unpriced_token_usage_records_totalused the provider type, for exampleanthropic. The two could not be correlated onprovider.The metric was also inconsistent with itself: the path where a provider fails to resolve labelled by instance name, and the path where a model has no price labelled by type. The type is still worth exposing, since prices are keyed on
(provider_type, model)and that is what an operator needs to add a price.Changes
provider(the instance name, consistent with the other gateway metrics) and addprovider_type(the configured type the price is keyed on).unknownforprovider_typewhen the provider does not resolve to a configured type.warninstead ofinfo. A missing price is an expected steady state, but a provider that cannot be resolved is not.metricsdocgenfixture.Closes AIGOV-574
Note
Initially generated by Claude Opus 5, modified and reviewed by @ssncferreira