mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-13 17:16:37 +08:00
added wpm, acc and duration histograms
This commit is contained in:
parent
9dae088202
commit
ac63198f74
1 changed files with 45 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue