Summary
Expose operational metrics for monitoring via Prometheus-compatible /metrics endpoint.
Motivation
Production deployments need observability. Prometheus is the standard for infrastructure metrics.
Metrics to Expose
Counters
distill_requests_total{endpoint, status} - Total requests by endpoint and status
distill_tokens_processed_total{stage} - Total tokens processed by stage
distill_cache_hits_total - Cache hits
distill_cache_misses_total - Cache misses
Histograms
distill_request_duration_seconds{endpoint} - Request latency
distill_reduction_ratio{stage} - Reduction ratio distribution
Gauges
distill_cache_size_bytes - Current cache size
distill_active_requests - Currently processing requests
Implementation
import "github.com/prometheus/client_golang/prometheus"
var (
requestsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "distill_requests_total",
Help: "Total requests by endpoint and status",
},
[]string{"endpoint", "status"},
)
requestDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "distill_request_duration_seconds",
Help: "Request latency distribution",
Buckets: prometheus.DefBuckets,
},
[]string{"endpoint"},
)
)
Deliverables
Acceptance Criteria
Summary
Expose operational metrics for monitoring via Prometheus-compatible
/metricsendpoint.Motivation
Production deployments need observability. Prometheus is the standard for infrastructure metrics.
Metrics to Expose
Counters
distill_requests_total{endpoint, status}- Total requests by endpoint and statusdistill_tokens_processed_total{stage}- Total tokens processed by stagedistill_cache_hits_total- Cache hitsdistill_cache_misses_total- Cache missesHistograms
distill_request_duration_seconds{endpoint}- Request latencydistill_reduction_ratio{stage}- Reduction ratio distributionGauges
distill_cache_size_bytes- Current cache sizedistill_active_requests- Currently processing requestsImplementation
Deliverables
/metricsendpoint in Prometheus formatAcceptance Criteria