@sp8d/diagnostics
Version:
sp8d-diagnostics: Advanced diagnostics, debugging, and observability for concurrent and distributed TypeScript/JavaScript systems. Detect race conditions, deadlocks, and monitor runtime.
38 lines • 1.4 kB
TypeScript
import type { Channel, ChannelStats } from "@sp8d/core";
export interface SlotState {
index: number;
status: number;
ageMs: number;
}
export interface ChannelDiagnostics {
readonly stats: ChannelStats & {
throughput: number;
consumerLag: number;
avgSlotAge: number;
maxSlotAge: number;
};
getSlotState(): SlotState[];
getHistory(): ChannelStats[];
start(): void;
stop(): void;
onUpdate(cb: (stats: ChannelDiagnostics["stats"]) => void): void;
}
export interface ChannelDiagnosticsOptions {
intervalMs?: number;
slotSample?: number | "all";
onUpdate?: (stats: ChannelDiagnostics["stats"]) => void;
}
/**
* Create diagnostics for a channel, with flexible options and developer-friendly API.
* @param channel The channel to monitor
* @param options Diagnostics options (intervalMs, slotSample, onUpdate)
*/
export declare function createChannelDiagnostics(channel: Channel, options?: ChannelDiagnosticsOptions): ChannelDiagnostics;
/**
* Start diagnostics in a worker thread for zero main-thread impact.
* @param channel The channel to monitor
* @param options Diagnostics options (intervalMs, slotSample, onUpdate)
* @returns The Worker instance
*/
export declare function startDiagnosticsWorker(channel: Channel, options?: ChannelDiagnosticsOptions): Worker;
//# sourceMappingURL=sp8d-diagnostics.d.ts.map