Skip to content

add support for Gradle prometheus metrics#124

Merged
andrew merged 3 commits into
git-pkgs:mainfrom
matikepa:gradle-metrics
May 22, 2026
Merged

add support for Gradle prometheus metrics#124
andrew merged 3 commits into
git-pkgs:mainfrom
matikepa:gradle-metrics

Conversation

@matikepa
Copy link
Copy Markdown
Contributor

@matikepa matikepa commented May 15, 2026

Follow-up to #114

This PR adds observability for the Gradle HTTP build cache handler by recording request, cache, and storage metrics through the existing Prometheus metrics package.

Copy link
Copy Markdown
Contributor

@andrew andrew left a comment

Choose a reason for hiding this comment

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

Thanks for splitting this out. The cache hit/miss and storage-operation instrumentation in handleGetOrHead / handlePut is good and matches the pattern already used in handler.go.

I'd like to drop the RecordRequest / statusCapturingResponseWriter part though. LoggerMiddleware in internal/server/middleware.go already wraps every request with a status-capturing writer and measures duration, so gradle requests end up double-wrapped, and more awkwardly this would make gradle the only ecosystem that shows up in RequestsTotal. The right place for RecordRequest is inside that middleware, deriving the ecosystem from the path prefix so every handler is covered at once. I'm happy to do that as a follow-up myself; for this PR could you remove the start/rw/defer block and statusCapturingResponseWriter, and revert the wrw renames in Routes()?

One small consistency nit while you're in there: the Size call records RecordStorageOperation inside both the success and error branches (and skips it when err == nil && size < 0). Everywhere else the pattern is to record the duration unconditionally right after the call, then if err != nil { RecordStorageError }. Would be good to match that.

The test's before/after delta approach on the global counters is the right way to do it.

@matikepa matikepa requested a review from andrew May 22, 2026 10:26
Copy link
Copy Markdown
Contributor

@andrew andrew left a comment

Choose a reason for hiding this comment

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

Both points addressed: the request-level wrapping is gone so this no longer overlaps LoggerMiddleware, and the Size timing now follows the unconditional-duration-then-error pattern. Instrumentation on Exists/Size/Open/Store and the hit/miss recording all look right.

Note #114 still has an older copy of these changes on its branch (I've asked for that commit to be dropped over there), so merge order will need a small amount of care.

@andrew andrew merged commit a8b6b0a into git-pkgs:main May 22, 2026
5 checks passed
@matikepa matikepa deleted the gradle-metrics branch May 22, 2026 11:28
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