@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
41 lines • 2.17 kB
TypeScript
/**
* Default cap on tracked error families. The map is the ONLY state the
* `new-exception` rule keeps, and it must stay bounded so a host that throws a
* long tail of unique error families (e.g. message-embedded ids that defeat the
* family hash) can never grow it without limit. At the cap we evict the OLDEST
* inserted family — the one least likely to still be "recently seen" — which is
* the correct bias for a recency-window dedup.
*/
declare const DEFAULT_MAX_FAMILIES = 10000;
/**
* Bounded, in-memory "have we seen this error family recently?" tracker backing
* the `new-exception` rule. Per-replica by design: it lives in process memory, so
* in a multi-replica deployment the SAME family may be reported as new once per
* pod (documented caveat — acceptable for v1; a cross-pod store would defeat the
* "cheap map lookup on the hot flush path" goal).
*
* Eviction uses a `Map`'s insertion-order iteration: the first key is the oldest
* INSERTED entry. We intentionally do NOT re-order on update (that would make it
* an LRU keyed on last-seen and complicate the cheap path); the window check
* already discards stale last-seen times, so insertion-order eviction is a sound,
* O(1) cap with no per-touch bookkeeping.
*/
export declare class NewExceptionTracker {
private readonly seen;
private readonly maxFamilies;
constructor(maxFamilies?: number);
/**
* Record an observation of `familyHash` at `nowMs` and report whether this is a
* NEW family for the `windowMs` window — i.e. it was either never seen or last
* seen longer ago than the window. Always updates the stored last-seen time so
* repeat occurrences refresh the window. Returns `true` only on a genuine
* first/expired occurrence (the signal that should fire the alert).
*/
observe(familyHash: string, nowMs: number, windowMs: number): boolean;
/** Number of tracked families (test/observability seam). */
get size(): number;
/** Evict the oldest entries until the map is within its cap. */
private evictIfNeeded;
}
export { DEFAULT_MAX_FAMILIES };
//# sourceMappingURL=new-exception-tracker.d.ts.map