UNPKG

@lokalise/fastify-extras

Version:

Opinionated set of fastify plugins, commonly used in Lokalise

33 lines (32 loc) 1.09 kB
import type { FastifyBaseLogger } from 'fastify'; import * as prometheus from 'prom-client'; import type { QueueDiscoverer } from './queueDiscoverers.js'; export type Metrics = { countGauge: prometheus.Gauge<'status' | 'queue'>; processedDuration: prometheus.Histogram<'status' | 'queue'>; finishedDuration: prometheus.Histogram<'status' | 'queue'>; }; export type MetricCollectorOptions = { bullMqPrefix: string; metricsPrefix: string; queueDiscoverer: QueueDiscoverer; excludedQueues: string[]; histogramBuckets: number[]; }; export declare class MetricsCollector { private readonly metrics; private readonly options; private readonly registry; private readonly logger; private observedQueues; constructor(options: MetricCollectorOptions, registry: prometheus.Registry, logger: FastifyBaseLogger); /** * Updates metrics for all discovered queues */ collect(): Promise<void>; /** * Stops the metrics collection and cleans up resources */ dispose(): Promise<void>; private registerMetrics; }