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
- 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
Overview
There is currently no way to observe the service's health in production beyond logs. A
/metricsendpoint in Prometheus format enables dashboards, alerting, and SLA tracking.Metrics to Expose
Price Oracle
smartdrop_price_fetch_totalsmartdrop_price_cache_hit_totalsmartdrop_price_cache_miss_totalsmartdrop_price_anomaly_totalsmartdrop_price_usdHTTP
http_request_duration_secondshttp_requests_totalSystem
redis_connectedprocess_uptime_secondsImplementation
src/metrics.jswith all metric definitions and agetRegistry()exportGET /metrics(plain text, no auth — restrict at infra level)priceOracle.jsat each source call and cache operationAcceptance Criteria
prom-clientinstalled and default metrics enabledGET /metricsreturns valid Prometheus text format/metricsexcluded from rate limiting