This commit is contained in:
seb
2026-10-19 01:53:25 +02:00
parent c958ecf604
commit e14a8ee8f0
5 changed files with 30 additions and 8 deletions

View File

@@ -97,14 +97,17 @@ export function performHealthSelftest() {
});
}
// MARK: returns raw (3h), avg and max (30d) latency series as [{ timestamp, value }] oldest first
export async function getLatencySeries() {
// MARK: returns latency series as [{ timestamp, value }] oldest first; range '3h' (default) = raw only, 'all' = raw + avg + max
export async function getLatencySeries({ range = '3h' } = {}) {
const redis = getRedisClient();
const parse = (members) =>
members.map((m) => {
const i = m.indexOf(':');
return { timestamp: Number(m.slice(0, i)), value: Number(m.slice(i + 1)) };
});
if (range === '3h') {
return { raw: parse(await redis.zrange(rawKey(), 0, -1)) };
}
const [raw, avg, max] = await Promise.all([
redis.zrange(rawKey(), 0, -1),
redis.zrange(avgKey(), 0, -1),