Skip to content

Refactor Metrics Registry to Support Dynamic Metrics Injection and Custom Labels #59

Description

@grantfox-oss

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions