Skip to content

Correct cache metrics - #272

Merged
andrew merged 1 commit into
mainfrom
cache-metrics
Aug 16, 2026
Merged

Correct cache metrics#272
andrew merged 1 commit into
mainfrom
cache-metrics

Conversation

@andrew

@andrew andrew commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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 gem and composer use canonical labels.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/metrics using purl.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.

@andrew
andrew merged commit 879e89e into main Aug 16, 2026
9 checks passed
@andrew
andrew deleted the cache-metrics branch August 16, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants