Skip to content

[Feature] Prometheus Metrics Endpoint #7

Description

@Siddhant-K-code

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

  • /metrics endpoint in Prometheus format
  • Grafana dashboard template (JSON)
  • Documentation for metrics

Acceptance Criteria

  • All metrics exposed correctly
  • Grafana dashboard works out of box
  • No significant performance impact (< 1% overhead)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions