// Prometheus metrics. Reusable counters/histograms for the API + cache. import { Counter, collectDefaultMetrics, Gauge, Histogram, Registry } from 'prom-client'; export const registry = new Registry(); collectDefaultMetrics({ register: registry }); export const httpRequests = new Counter({ name: 'http_requests_total', help: 'Total HTTP requests', labelNames: ['method', 'route', 'status'], registers: [registry], }); export const httpDuration = new Histogram({ name: 'http_request_duration_seconds', help: 'HTTP request duration in seconds', labelNames: ['method', 'route', 'status'], buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5], registers: [registry], }); export const searchCacheHits = new Counter({ name: 'search_cache_hits_total', help: 'Number of search results served from the LRU cache', registers: [registry], }); export const searchCacheMisses = new Counter({ name: 'search_cache_misses_total', help: 'Number of search requests that bypassed the cache', registers: [registry], }); export const imdbRatingsCount = new Gauge({ name: 'imdb_ratings_total', help: 'Number of IMDb ratings currently loaded in memory', registers: [registry], }); export const searchWorkers = new Gauge({ name: 'search_workers', help: 'Number of active search workers per type', labelNames: ['type'], registers: [registry], });