import type { DashboardDB, MetricSnapshotRow } from './db.js'; /** * Aggregate relay-server snapshot consumed by MetricsCollector. Always * has the same shape as `RelayStats` from `@origintrail-official/dkg-core` * minus the unbounded `reservations[]` array — that lives only on the * live `/api/relay/stats` route, not in the periodic SQLite snapshot * (per-reservee detail would blow up the snapshot row size and isn't * useful for time-series graphing). The source returns `null` when the * node is not running a relay server. */ export interface RelayStatsSnapshot { capacity: number; reservationCount: number; activeCircuits: number; bytesIn: bigint; bytesOut: bigint; } export interface MetricsSource { getPeerCount(): number; getDirectPeerCount(): number; getRelayedPeerCount(): number; getMeshPeerCount(): number; getContextGraphCount(): Promise; getTotalTriples(): Promise; getTotalKCs(): Promise; getTotalKAs(): Promise; getConfirmedKCs(): Promise; getTentativeKCs(): Promise; getStoreBytes(): Promise; getRpcLatencyMs(): Promise; isRpcHealthy(): Promise; /** * Optional. Returns a relay snapshot on Core Nodes (relay server enabled), * or null on edge nodes. Method is optional so existing tests / external * consumers of MetricsSource don't have to stub it. */ getRelayStats?(): RelayStatsSnapshot | null; } /** * Periodically collects system, network, knowledge, and chain metrics * and stores them as snapshots in SQLite. */ export declare class MetricsCollector { private readonly db; private readonly source; private readonly dataDir?; /** * Gate for the expensive store-scan getters (#1066 Item 1). When it returns * false the tick skips the full-store COUNT scans and leaves those columns * null. Defaults to always-collect so existing callers/tests are unchanged. */ private readonly shouldCollectStoreMetrics; private timer; private prevCpuTimes; private readonly startTime; constructor(db: DashboardDB, source: MetricsSource, dataDir?: string | undefined, /** * Gate for the expensive store-scan getters (#1066 Item 1). When it returns * false the tick skips the full-store COUNT scans and leaves those columns * null. Defaults to always-collect so existing callers/tests are unchanged. */ shouldCollectStoreMetrics?: () => boolean); start(): void; private backfillNulls; stop(): void; collectAndStore(): Promise; collect(): Promise; private measureCpu; } //# sourceMappingURL=metrics-collector.d.ts.map