/** * @file metrics.service.ts * @description Core service backing the `/metrics` endpoint (issue #397). */ import type { MetricsOptionsInterface } from '../common'; interface CounterSnapshotEntry { name: string; count: number; attributes: Record; } interface GaugeSnapshotEntry { name: string; value: number; attributes?: Record; help?: string; } interface ProcessStatsCollector { collect(): GaugeSnapshotEntry[]; } /** * Lazily build a `ProcessStatsCollector` when the metrics config selects the * `process` category (or omits `include` entirely, which means "every * category"). Returns `undefined` when process metrics are filtered out so * the per-scrape `process.cpuUsage()` / `monitorEventLoopDelay()` calls don't * run for nothing. * * Uses the same lazy `require('@frontmcp/observability')` as the snapshot * source so the SDK ↔ observability import cycle stays broken at module * init. */ export declare function createProcessStatsCollectorIfEnabled(config: MetricsOptionsInterface): ProcessStatsCollector | undefined; /** * Resolved metrics body + content type, returned by `getMetrics()`. */ export interface MetricsResponse { contentType: string; body: string; } /** * Test-injection seam for the counter snapshot source — production callers * never set this. */ export interface MetricsServiceOptions { snapshotSource?: () => CounterSnapshotEntry[]; } export declare class MetricsService { private readonly config; private readonly processCollector?; private readonly snapshotSource; private readonly resolvedToken?; constructor(config: MetricsOptionsInterface, processCollector?: ProcessStatsCollector, options?: MetricsServiceOptions); /** * Render the current metrics scrape in the configured format. */ getMetrics(): MetricsResponse; /** * Check the supplied `Authorization` header against the configured auth * policy. Returns the HTTP status the route should respond with: * - 200 — the request is allowed to read metrics * - 401 — missing credentials when token auth is configured * - 403 — wrong credentials */ authorize(authorizationHeader: string | undefined): 200 | 401 | 403; } export {}; //# sourceMappingURL=metrics.service.d.ts.map