@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
21 lines • 1.24 kB
TypeScript
/**
* Estimates a percentile from a pre-aggregated latency histogram (O(buckets),
* no raw scan). Nearest-rank style at BUCKET resolution: the result is the UPPER
* boundary of the bucket that contains the target rank, so the estimate is an
* APPROXIMATION whose error is bounded by that bucket's width.
*
* - `total = Σ histogram`; `target rank = fraction * total` (1-based, matching
* the raw nearest-rank `Math.ceil(fraction * n)`).
* - Walk the cumulative count until it reaches/crosses the target rank; return
* the containing bucket's upper boundary.
* - The OVERFLOW bucket (values greater than the last boundary) has no finite
* upper boundary; we return the LAST boundary as a safe finite representative
* (documented under-estimate for the unbounded tail, never `Infinity`).
* - Returns 0 when the histogram is empty / total is 0.
*
* @param histogram fixed-length latency histogram (legacy/short arrays are
* normalized to zeros first, so this never throws or yields NaN).
* @param fraction percentile fraction in [0, 1] (e.g. 0.5, 0.95, 0.99).
*/
export declare function estimatePercentileFromHistogram(histogram: number[], fraction: number): number;
//# sourceMappingURL=estimate-percentile.d.ts.map