You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-12-12 21:21:15 +03:00
feat(client): add latency histogram (#3099)
* add latency histogram command, tests (##1955)
This commit is contained in:
committed by
GitHub
parent
38bfaa7c90
commit
dae47b4820
93
packages/client/lib/commands/LATENCY_HISTOGRAM.spec.ts
Normal file
93
packages/client/lib/commands/LATENCY_HISTOGRAM.spec.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import assert from "node:assert/strict";
|
||||
import testUtils, { GLOBAL } from "../test-utils";
|
||||
import LATENCY_HISTOGRAM from "./LATENCY_HISTOGRAM";
|
||||
import { parseArgs } from "./generic-transformers";
|
||||
|
||||
describe("LATENCY HISTOGRAM", () => {
|
||||
describe("transformArguments", () => {
|
||||
it("filtered by command set", () => {
|
||||
assert.deepEqual(parseArgs(LATENCY_HISTOGRAM, "set"), [
|
||||
"LATENCY",
|
||||
"HISTOGRAM",
|
||||
"set",
|
||||
]);
|
||||
});
|
||||
|
||||
it("unfiltered", () => {
|
||||
assert.deepEqual(parseArgs(LATENCY_HISTOGRAM), [
|
||||
"LATENCY",
|
||||
"HISTOGRAM",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("RESP 2", () => {
|
||||
testUtils.testWithClient(
|
||||
"unfiltered list",
|
||||
async (client) => {
|
||||
await client.configResetStat();
|
||||
await Promise.all([
|
||||
client.lPush("push-key", "hello "),
|
||||
client.set("set-key", "world!"),
|
||||
]);
|
||||
const histogram = await client.latencyHistogram();
|
||||
const commands = ["config|resetstat", "set", "lpush"];
|
||||
for (const command of commands) {
|
||||
assert.ok(typeof histogram[command]["calls"], "number");
|
||||
}
|
||||
},
|
||||
GLOBAL.SERVERS.OPEN,
|
||||
);
|
||||
|
||||
testUtils.testWithClient(
|
||||
"filtered by a command list",
|
||||
async (client) => {
|
||||
await client.configSet("latency-monitor-threshold", "100");
|
||||
await client.set("set-key", "hello");
|
||||
const histogram = await client.latencyHistogram("set");
|
||||
assert.ok(typeof histogram.set["calls"], "number");
|
||||
},
|
||||
GLOBAL.SERVERS.OPEN,
|
||||
);
|
||||
});
|
||||
|
||||
describe("RESP 3", () => {
|
||||
testUtils.testWithClient(
|
||||
"unfiltered list",
|
||||
async (client) => {
|
||||
await client.configResetStat();
|
||||
await Promise.all([
|
||||
client.lPush("push-key", "hello "),
|
||||
client.set("set-key", "world!"),
|
||||
]);
|
||||
const histogram = await client.latencyHistogram();
|
||||
const commands = ["config|resetstat", "set", "lpush"];
|
||||
for (const command of commands) {
|
||||
assert.ok(typeof histogram[command]["calls"], "number");
|
||||
}
|
||||
},
|
||||
{
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
testUtils.testWithClient(
|
||||
"filtered by a command list",
|
||||
async (client) => {
|
||||
await client.configSet("latency-monitor-threshold", "100");
|
||||
await client.set("set-key", "hello");
|
||||
const histogram = await client.latencyHistogram("set");
|
||||
assert.ok(typeof histogram.set["calls"], "number");
|
||||
},
|
||||
{
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user