Skip to content

Enhanced Prometheus Metrics #185

@mftee

Description

@mftee

Extend the existing MetricsRegistry with histogram and gauge metrics to provide richer observability over the service's performance and state.

Requirements:

  • Add the following metrics to MetricsRegistry:
    • request_duration_seconds (Histogram with buckets: 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5) — HTTP request latency
    • stellar_query_duration_seconds (Histogram) — Stellar Horizon query latency
    • cache_size_entries (Gauge) — approximate number of entries in Redis cache
    • active_connections (Gauge) — number of active HTTP connections
    • circuit_breaker_state (Gauge with label state) — 0=closed, 1=half-open, 2=open
  • Implement MetricsRegistry::observe_request_duration(duration: f64) and observe_stellar_duration(duration: f64)
  • Add Axum middleware that measures request duration and calls observe_request_duration after the response is sent
  • All metrics must have descriptive help strings

Acceptance Criteria:

  • GET /metrics returns valid Prometheus text format including the new histograms and gauges
  • Histogram buckets are correctly configured
  • Middleware correctly measures end-to-end request time
  • Unit tests verify metrics are incremented/observed correctly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions