Skip to content

Add Prometheus metrics endpoint for Fly.io Grafana#55

Merged
xumaple merged 5 commits intomainfrom
xumaple/copilot/metrics
Apr 11, 2026
Merged

Add Prometheus metrics endpoint for Fly.io Grafana#55
xumaple merged 5 commits intomainfrom
xumaple/copilot/metrics

Conversation

@xumaple
Copy link
Copy Markdown
Owner

@xumaple xumaple commented Apr 4, 2026

Summary

  • Adds metrics and metrics-exporter-prometheus crates for per-endpoint Prometheus metrics
  • New middleware records http_requests_total (counter) and http_request_duration_seconds (histogram), labeled by method, path template, and status code
  • GET /metrics endpoint serves Prometheus exposition format
  • fly.toml configured with [metrics] section so Fly.io scrapes automatically
  • build_router_with_burst accepts a PrometheusHandle param for testability

Closes #14

Test plan

  • Unit tests pass (32 tests)
  • Integration tests pass (20 tests, including new test_metrics_endpoint)
  • Clippy clean
  • After deploy: verify metrics appear in Fly.io Grafana dashboard

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
website Ready Ready Preview, Comment Apr 11, 2026 4:12am

Comment thread passwords/api/src/lib.rs Outdated
Comment thread passwords/api/src/lib.rs Outdated
xumaple and others added 5 commits April 11, 2026 00:08
Adds per-endpoint request count and latency metrics via the metrics
and metrics-exporter-prometheus crates. GET /metrics serves Prometheus
exposition format. fly.toml configured to point Fly.io scraper at it.
Closes #14.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Swap custom middleware for the axum-prometheus crate which provides
the same per-endpoint counters and histograms out of the box.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove build_router_with_burst_no_metrics. Cache the prometheus
layer/handle pair in a OnceLock so build_router_with_burst is safe
to call multiple times and always returns the full prod middleware
stack.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename to build_router(RouterConfig) — takes a config struct instead
of a bare u32. Remove the convenience wrapper. Improve doc comments
to focus on what the function does rather than implementation details.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xumaple xumaple force-pushed the xumaple/copilot/metrics branch from 8c11aea to 762a20f Compare April 11, 2026 04:12
@xumaple xumaple merged commit 86dbeed into main Apr 11, 2026
7 of 8 checks passed
@xumaple xumaple deleted the xumaple/copilot/metrics branch April 11, 2026 04: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.

Add metrics to backend

1 participant