import type { MetricCollector } from '../collectors/collector.js'; import type { MetricValue } from '../types.js'; /** * Health status for an individual collector. */ export interface CollectorHealth { name: string; label: string; status: 'healthy' | 'errored' | 'stopped'; lastError: string | null; lastErrorAt: number | null; } /** * Central orchestrator that runs all configured collectors in parallel * and merges their results into a single flat record. * * The provider creates one `StatsEngine` instance at app boot, binds * it to the container as `'server_stats.engine'`, and runs * {@link collect} on a timer every `intervalMs` milliseconds. * * @example Accessing the engine from a controller * ```ts * const engine = await app.container.make('server_stats.engine') as StatsEngine * return response.json(engine.getLatestStats()) * ``` */ export declare class StatsEngine { private collectors; private latestStats; private collectorHealth; constructor(collectors: MetricCollector[]); /** * Initialize all collectors. * * Calls each collector's `start()` method (if defined) sequentially. * Called once by the provider during the `ready` phase. */ start(): Promise; /** * Shut down all collectors. * * Calls each collector's `stop()` method (if defined) sequentially. * Called by the provider during app shutdown. */ stop(): Promise; /** * Run all collectors in parallel, merge their results, and return * the combined stats snapshot. * * A `timestamp` field is automatically added. If any collector throws, * its error is caught and that collector's metrics are omitted from * the result. */ collect(): Promise>; /** * Returns the most recent stats snapshot from the last `collect()` call. * * Returns an empty object if `collect()` has not been called yet. */ getLatestStats(): Record; /** Returns health status for all collectors. */ getCollectorHealth(): CollectorHealth[]; /** Returns collector-specific configuration for all collectors. */ getCollectorConfigs(): Array<{ name: string; config: Record; }>; }