u
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user