Skip to content

feat: add Prometheus metrics endpoint#19

Merged
Siddhant-K-code merged 2 commits into
mainfrom
feat/prometheus-metrics
Feb 14, 2026
Merged

feat: add Prometheus metrics endpoint#19
Siddhant-K-code merged 2 commits into
mainfrom
feat/prometheus-metrics

Conversation

@Siddhant-K-code

Copy link
Copy Markdown
Owner

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/dedupe wrapped with metrics middleware, /metrics endpoint added, dedup stats recorded per request
  • cmd/serve.go/v1/retrieve wrapped with metrics middleware, old JSON /metrics replaced with Prometheus format, dedup stats recorded per request
  • grafana/dashboard.json — 10-panel Grafana dashboard: request rate, error rate, p99 latency, active requests, latency percentiles, chunks processed, reduction ratio, clusters formed, status code breakdown
  • README.md — Monitoring section with metrics table and Prometheus scrape config

Metrics exposed

Metric Type Labels
distill_requests_total Counter endpoint, status
distill_request_duration_seconds Histogram endpoint
distill_chunks_processed_total Counter direction
distill_reduction_ratio Histogram endpoint
distill_active_requests Gauge
distill_clusters_formed_total Counter endpoint

Plus Go runtime and process metrics.

Testing

  • 8 unit tests covering: creation, request recording, dedup recording, middleware (success + error), handler output, active requests tracking
  • All existing tests pass
  • go vet clean

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]>
@Siddhant-K-code Siddhant-K-code added the enhancement New feature or request label Feb 14, 2026
@Siddhant-K-code Siddhant-K-code merged commit 0f8a10d into main Feb 14, 2026
2 checks passed
@Siddhant-K-code Siddhant-K-code deleted the feat/prometheus-metrics branch February 14, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Prometheus Metrics Endpoint

1 participant