@newrelic/preflight 1.14.11 → 1.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ import { computePercentile } from '../../metrics/percentile.js';
2
+ function computePercentilesFromDurations(durations) {
3
+ if (durations.length === 0)
4
+ return null;
5
+ const sorted = [...durations].sort((a, b) => a - b);
6
+ const count = sorted.length;
7
+ return {
8
+ p50: computePercentile(sorted, 0.5) ?? 0,
9
+ p95: computePercentile(sorted, 0.95) ?? 0,
10
+ p99: computePercentile(sorted, 0.99) ?? 0,
11
+ min: sorted[0],
12
+ max: sorted[count - 1],
13
+ count,
14
+ };
15
+ }
16
+ // Computes the same p50/p95/p99/min/max/count shape LatencyTracker produces
17
+ // incrementally for one process, but from a flat snapshot of samples
18
+ // gathered across every process/session active today — see the aggregate
19
+ // route in api-handler.ts, which is the only caller.
20
+ export function computeLatencyPercentiles(samples) {
21
+ const byToolDurations = new Map();
22
+ const allDurations = [];
23
+ for (const sample of samples) {
24
+ allDurations.push(sample.durationMs);
25
+ const arr = byToolDurations.get(sample.toolName);
26
+ if (arr) {
27
+ arr.push(sample.durationMs);
28
+ }
29
+ else {
30
+ byToolDurations.set(sample.toolName, [sample.durationMs]);
31
+ }
32
+ }
33
+ const byTool = {};
34
+ for (const [toolName, durations] of byToolDurations) {
35
+ byTool[toolName] = computePercentilesFromDurations(durations);
36
+ }
37
+ return {
38
+ overall: computePercentilesFromDurations(allDurations),
39
+ byTool,
40
+ };
41
+ }
42
+ //# sourceMappingURL=latency-percentiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latency-percentiles.js","sourceRoot":"","sources":["../../../src/dashboard/routes/latency-percentiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAahE,SAAS,+BAA+B,CAAC,SAA4B;IACnE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAA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