added wpm, acc and duration histograms

This commit is contained in:
Miodec 2022-03-12 18:29:32 +01:00
parent 9dae088202
commit ac63198f74

View file

@ -1,5 +1,5 @@
import "dotenv/config";
import { Counter } from "prom-client";
import { Counter, Histogram } from "prom-client";
const auth = new Counter({
name: "api_request_auth_total",
@ -34,6 +34,32 @@ const resultFunbox = new Counter({
labelNames: ["funbox"],
});
const resultWpm = new Histogram({
name: "result_wpm",
help: "Result wpm",
labelNames: ["mode", "mode2"],
buckets: [
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170,
180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290,
],
});
const resultAcc = new Histogram({
name: "result_acc",
help: "Result accuracy",
labelNames: ["mode", "mode2"],
buckets: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
});
const resultDuration = new Histogram({
name: "result_duration",
help: "Result duration",
buckets: [
5, 10, 15, 30, 45, 60, 90, 120, 250, 500, 750, 1000, 1250, 1500, 1750, 2000,
2500, 3000,
],
});
export function incrementAuth(type: "Bearer" | "ApeKey" | "None"): void {
auth.inc({ type });
}
@ -81,4 +107,22 @@ export function incrementResult(
resultFunbox.inc({
funbox: funbox || "none",
});
resultWpm.observe(
{
mode,
mode2: m2,
},
res.wpm
);
resultAcc.observe(
{
mode,
mode2: m2,
},
res.acc
);
resultDuration.observe(res.testDuration);
}