Redesign the MetricsRegistry to support dynamic metric registration, custom label injection, and metrics inheritance for derived components. Enable upstream consumers to add domain-specific metrics without modifying core registry.
- Affected files:
src/metrics.rs (MetricsRegistry trait design and dynamic registration)
src/cache.rs (cache metrics factory and label binding)
src/rate_limit.rs (rate limit metrics injection points)
src/stellar.rs (Horizon client metrics hooks)
- Acceptance criteria:
- MetricsRegistry trait with
register_counter(), register_gauge(), register_histogram() methods
- Metrics accept context labels (issuer, endpoint, algorithm) without code duplication
- Downstream components (StellarClient, PerIssuerRateLimiter) inject metrics via constructor
- Unit tests verify metrics are recorded accurately with correct labels
- Benchmarks show < 5% overhead from dynamic metric lookup
- Documentation includes examples of registering custom metrics
Redesign the MetricsRegistry to support dynamic metric registration, custom label injection, and metrics inheritance for derived components. Enable upstream consumers to add domain-specific metrics without modifying core registry.
src/metrics.rs(MetricsRegistry trait design and dynamic registration)src/cache.rs(cache metrics factory and label binding)src/rate_limit.rs(rate limit metrics injection points)src/stellar.rs(Horizon client metrics hooks)register_counter(),register_gauge(),register_histogram()methods