Skip to content

[metrics]: Add Prometheus metrics module#46

Open
pseudomuto wants to merge 1 commit into
mainfrom
metrics_package
Open

[metrics]: Add Prometheus metrics module#46
pseudomuto wants to merge 1 commit into
mainfrom
metrics_package

Conversation

@pseudomuto

Copy link
Copy Markdown
Collaborator

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.

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

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/metrics fx module to construct a Prometheus-backed go-metrics instance and serve /metrics via an HTTP server bound to the fx lifecycle.
  • Wire the metrics module into cmd/proxy/serve.go with a new --metrics-addr flag.
  • 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.

Comment thread internal/metrics/fx.go
Comment thread internal/metrics/fx.go
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.
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