Skip to content

Add custom business metrics for stream creation rate and webhook delivery success via prom-client #237

@Jagadeeshftw

Description

@Jagadeeshftw

Description

src/middleware/httpMetrics.ts captures generic HTTP metrics but no domain-specific business metrics are instrumented. Operators cannot alert on webhook delivery failure rates, stream creation throughput, or indexer ingestion lag using the existing Prometheus data. Custom prom-client metrics must be added across src/routes/streams.ts, src/webhooks/service.ts, and src/indexer/service.ts.

Requirements and context

  • Register the following prom-client metrics: fluxora_streams_created_total (counter, labels: status), fluxora_webhook_deliveries_total (counter, labels: outcome), fluxora_webhook_delivery_duration_seconds (histogram), fluxora_indexer_events_ingested_total (counter), fluxora_indexer_lag_seconds (gauge)
  • Instrument each metric at the appropriate callsite in source files
  • Ensure metrics are de-registered cleanly between vitest test runs to avoid duplicate registration errors
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested execution

Fork the repo and create a branch

git checkout -b feature/custom-business-metrics

Implement changes

  • Update/Write: src/metrics/businessMetrics.ts — register all custom prom-client metrics
  • Update/Write: src/routes/streams.ts, src/webhooks/service.ts, src/indexer/service.ts — instrument metrics
  • Write comprehensive tests: tests/metrics/businessMetrics.test.ts
  • Add documentation: docs/observability.md — document each metric, labels, and alerting recommendations
  • Include clear code comments and types
  • Validate security assumptions

Test and commit

  • Run tests: pnpm test (or pnpm test:coverage)
  • Cover edge cases: metric incremented on success, metric incremented on failure, histogram bucket distribution, duplicate registration guard
  • Include test output and security notes

Example commit message

feat: add custom business metrics for streams, webhooks, and indexer

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbackendBackend service workenhancementNew feature or improvementobservabilityLogging / metrics / tracing

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions