feat: integrate Prometheus metrics for HTTP requests and worker performance#17
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR introduces Prometheus metrics instrumentation across the application. It adds HTTP request metrics via middleware, defines a metrics package with Prometheus counter, histogram, and gauge metrics, registers a Changes
Sequence DiagramsequenceDiagram
actor Client
participant Router as HTTP Router
participant Middleware as MetricsMiddleware
participant Handler as Request Handler
participant Metrics as Prometheus Metrics
Client->>Router: HTTP Request
Router->>Middleware: Pass to middleware chain
Middleware->>Middleware: Start timer, wrap ResponseWriter
Middleware->>Handler: Call next handler
Handler->>Handler: Process request
Handler->>Middleware: Write response + status
Middleware->>Metrics: Record HTTPRequestsTotal<br/>(method, path, status)
Middleware->>Metrics: Record HTTPRequestDuration<br/>(method, path, duration)
Middleware->>Client: Return response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Exposes a
/metricsendpoint and instruments the HTTP layer, queue admission, and claim expiry with Prometheus counters, gauges, and histograms.Changes
internal/metricspackage declaring all application metrics viapromautoMetricsMiddlewareto capture HTTP request count and duration per route pattern (uses chi route context to avoid UUID cardinality)/metricshandler on the router usingpromhttp.HandlerAdmissionWorker— records tick duration, tick errors, and admitted-per-event countExpiryWorker— records expired claim count per eventfairqueueandfairqueue-loadtestscrape targets toprometheus.ymlNotes
prometheus/client_golangSummary by CodeRabbit
New Features
/metricsendpoint for Prometheus-based monitoring and observability