feat: add Prometheus metrics endpoint#19
Merged
Conversation
Add /metrics endpoint with Prometheus-compatible instrumentation: - pkg/metrics: counters, histograms, gauges for requests, latency, chunks processed, reduction ratio, active requests, clusters formed - Middleware wraps /v1/dedupe and /v1/retrieve handlers - Replaces the old JSON /metrics in serve.go - Grafana dashboard template (grafana/dashboard.json) - 8 unit tests for metrics package - README monitoring section with scrape config Closes #7 Co-authored-by: Ona <[email protected]>
Co-authored-by: Ona <[email protected]>
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.
Motivation
Production deployments need observability. Prometheus is the standard for infrastructure metrics.
Closes #7
Changes
pkg/metrics/— Prometheus collectors: request counter, latency histogram, chunks processed, reduction ratio, active requests gauge, clusters formed counter. Includes HTTP middleware for automatic instrumentation.cmd/api.go—/v1/dedupewrapped with metrics middleware,/metricsendpoint added, dedup stats recorded per requestcmd/serve.go—/v1/retrievewrapped with metrics middleware, old JSON/metricsreplaced with Prometheus format, dedup stats recorded per requestgrafana/dashboard.json— 10-panel Grafana dashboard: request rate, error rate, p99 latency, active requests, latency percentiles, chunks processed, reduction ratio, clusters formed, status code breakdownREADME.md— Monitoring section with metrics table and Prometheus scrape configMetrics exposed
distill_requests_totaldistill_request_duration_secondsdistill_chunks_processed_totaldistill_reduction_ratiodistill_active_requestsdistill_clusters_formed_totalPlus Go runtime and process metrics.
Testing
go vetclean