Skip to content

Add Prometheus metrics endpoint for operational visibility #18

Description

@prodbycorne

Overview

There is currently no way to observe the service's health in production beyond logs. A /metrics endpoint in Prometheus format enables dashboards, alerting, and SLA tracking.

Metrics to Expose

Price Oracle

Metric Type Description
smartdrop_price_fetch_total Counter Price fetches by source and status (success/error)
smartdrop_price_cache_hit_total Counter Redis cache hits
smartdrop_price_cache_miss_total Counter Redis cache misses
smartdrop_price_anomaly_total Counter Price anomalies detected by asset
smartdrop_price_usd Gauge Current price per asset

HTTP

Metric Type Description
http_request_duration_seconds Histogram Request latency by route and status
http_requests_total Counter Total requests by method, route, status

System

Metric Type Description
redis_connected Gauge 1 if Redis is reachable, 0 otherwise
process_uptime_seconds Gauge Service uptime

Implementation

npm install prom-client
  • Create src/metrics.js with all metric definitions and a getRegistry() export
  • Add HTTP middleware to record latency and status per route
  • Expose GET /metrics (plain text, no auth — restrict at infra level)
  • Instrument priceOracle.js at each source call and cache operation

Acceptance Criteria

  • prom-client installed and default metrics enabled
  • GET /metrics returns valid Prometheus text format
  • All metrics above implemented
  • Middleware automatically instruments all routes
  • /metrics excluded from rate limiting
  • Integration test asserts metric names appear in response

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignfeatureNew feature or enhancementobservabilityLogging, metrics, tracing, monitoring

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions