import { type Overview, type OverviewOptions } from './overview.js'; import type { NormalizedSpan } from './types.js'; export interface HistogramBin { fromMs: number; toMs: number; count: number; } export interface Histogram { /** Equal-width bins from 0 to the p99; the last one also holds everything slower (see `overflow`). */ bins: HistogramBin[]; /** How many calls were slower than the last bin's upper edge. */ overflow: number; total: number; p50Ms: number; p95Ms: number; p99Ms: number; } export interface Speed { medianMs: number; count: number; /** Share of all calls, 0…1. */ share: number; } export interface VersionRow { version: string; count: number; p50Ms: number; p95Ms: number; errorRate: number; } export interface OperationDetails { /** null when the calls come from several services (no `service` filter) or there are none. */ service: string | null; operation: string; overview: Overview; /** null without calls in the window. Cold starts are left out (counted in `coldStarts`). */ histogram: Histogram | null; /** Two clearly separate latency groups — a cache hit and a miss, a fast path and a slow one, v1 and v2. */ speeds: [Speed, Speed] | null; versions: VersionRow[]; coldStarts: number; lastSeenMs: number | null; } export declare function latencyHistogram(durations: number[], bins?: number): Histogram | null; /** * Splits the calls into a fast and a slow group where that split explains the most variance (1-D 2-means on log * latency — latency is multiplicative: 20 → 40 ms is as big a step as 1 → 2 s). Reported only when the groups are * really apart: medians ×3 or more, and the smaller group is at least 10% of the calls and at least 3 of them. */ export declare function findSpeeds(durations: number[]): [Speed, Speed] | null; export declare function computeOperation(spans: NormalizedSpan[], options: OverviewOptions & { operation: string; }): OperationDetails;