[metrics]: Add Prometheus metrics module#46
Open
pseudomuto wants to merge 1 commit into
Open
Conversation
dd573ba to
c8b9328
Compare
There was a problem hiding this comment.
Pull request overview
Adds an internal/metrics fx module that wires HashiCorp go-metrics to a Prometheus sink and exposes it via an HTTP /metrics endpoint, then integrates it into the proxy serve command and validates behavior with lifecycle-focused tests.
Changes:
- Introduce
internal/metricsfx module to construct a Prometheus-backedgo-metricsinstance and serve/metricsvia an HTTP server bound to the fx lifecycle. - Wire the metrics module into
cmd/proxy/serve.gowith a new--metrics-addrflag. - Add tests covering lifecycle scrape behavior and failure/shutdown behavior.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/metrics/fx.go | Adds the metrics fx module, Prometheus sink construction, and lifecycle-managed HTTP server. |
| internal/metrics/fx_test.go | Adds end-to-end tests for /metrics scraping across Start/Stop and listener-failure shutdown behavior. |
| internal/metrics/doc.go | Adds package-level documentation for the metrics module. |
| cmd/proxy/serve.go | Wires the metrics module into the serve command and adds CLI/config plumbing for the listen address. |
| go.mod | Adds github.com/hashicorp/go-metrics dependency (and indirect deps). |
| go.sum | Records checksums for newly added module dependencies. |
Introduce internal/metrics, an fx module that constructs a hashicorp go-metrics instance backed by a Prometheus sink and serves it at /metrics over HTTP. The server is bound to the fx lifecycle: it starts in a background goroutine on OnStart and shuts down gracefully on OnStop, bringing the whole app down with a non-zero exit code if it stops for any reason other than a clean shutdown. Wire the module into the serve command and add tests covering provider construction, an end-to-end /metrics scrape across the lifecycle, and the missing-address failure path.
c8b9328 to
d7620d7
Compare
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.
Introduce internal/metrics, an fx module that constructs a hashicorp go-metrics instance backed by a Prometheus sink and serves it at /metrics over HTTP. The server is bound to the fx lifecycle: it starts in a background goroutine on OnStart and shuts down gracefully on OnStop, bringing the whole app down with a non-zero exit code if it stops for any reason other than a clean shutdown.
Wire the module into the serve command and add tests covering provider construction, an end-to-end /metrics scrape across the lifecycle, and the missing-address failure path.