()
| 75 | s.add(value); |
| 76 | }, |
| 77 | getAll() { |
| 78 | const result: Record<string, number> = Object.fromEntries(metrics); |
| 79 | for (const [name, h] of histograms) { |
| 80 | if (h.count === 0) { |
| 81 | continue; |
| 82 | } |
| 83 | result[`${name}_count`] = h.count; |
| 84 | result[`${name}_min`] = h.min; |
| 85 | result[`${name}_max`] = h.max; |
| 86 | result[`${name}_avg`] = h.sum / h.count; |
| 87 | const sorted = [...h.reservoir].sort((a, b) => a - b); |
| 88 | result[`${name}_p50`] = percentile(sorted, 50); |
| 89 | result[`${name}_p95`] = percentile(sorted, 95); |
| 90 | result[`${name}_p99`] = percentile(sorted, 99); |
| 91 | } |
| 92 | for (const [name, s] of sets) { |
| 93 | result[name] = s.size; |
| 94 | } |
| 95 | return result; |
| 96 | } |
| 97 | }; |
| 98 | } |
| 99 | export const StatsContext = createContext<StatsStore | null>(null); |
nothing calls this directly
no test coverage detected