Correct cache metrics - #272
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts Prometheus cache metrics so hit/miss accounting matches actual cache decision points and uses consistent (canonical) ecosystem labels, improving observability accuracy across artifact and metadata flows.
Changes:
- Normalize cache hit/miss metric ecosystem labels within
internal/metricsusingpurl.NormalizeEcosystem. - Move artifact cache miss recording to the points where cache lookup conclusively fails (including URL-based artifact fetch paths).
- Refine metadata cache metrics: record hits only when serving fresh metadata from local cache, and record misses only when metadata caching is enabled and requests fall through to upstream; add/extend tests to validate behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/metrics/metrics.go | Normalizes cache hit/miss metric labels at the metrics boundary. |
| internal/metrics/metrics_test.go | Adds/updates tests to assert cache metric label normalization behavior. |
| internal/handler/handler.go | Moves cache miss/hit accounting to the actual artifact/metadata cache decision points. |
| internal/handler/handler_test.go | Adds assertions verifying cache miss/hit deltas for artifact and metadata code paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Move artifact cache miss accounting to both cache lookup decision points, including URL-based downloads and failed upstream resolutions.
Count metadata cache hits only when fresh metadata is served locally, and misses when an enabled metadata cache falls through to upstream. Normalize cache metric labels at the metrics package boundary so aliases such as
gemandcomposeruse canonical labels.