mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-10 17:04:49 +08:00
logging busiest uids
This commit is contained in:
parent
8389970963
commit
b00e5d893e
2 changed files with 15 additions and 0 deletions
|
@ -9,6 +9,7 @@ import {
|
|||
incrementAuth,
|
||||
recordAuthTime,
|
||||
recordRequestCountry,
|
||||
recordRequestForUid,
|
||||
} from "../utils/prometheus";
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
|
@ -94,6 +95,10 @@ function authenticateRequest(authOptions = DEFAULT_OPTIONS): Handler {
|
|||
recordRequestCountry(country, req as MonkeyTypes.Request);
|
||||
}
|
||||
|
||||
if (req.method !== "OPTIONS" && req?.ctx?.decodedToken?.uid) {
|
||||
recordRequestForUid(req.ctx.decodedToken.uid);
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -257,3 +257,13 @@ const tokenCacheLength = new Gauge({
|
|||
export function setTokenCacheLength(length: number): void {
|
||||
tokenCacheLength.set(length);
|
||||
}
|
||||
|
||||
const uidRequestCount = new Counter({
|
||||
name: "user_request_count",
|
||||
help: "Request count per uid",
|
||||
labelNames: ["uid"],
|
||||
});
|
||||
|
||||
export function recordRequestForUid(uid: string): void {
|
||||
uidRequestCount.inc({ uid });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue