mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-04 02:34:43 +08:00
impr(server): log server versions which generate 500 errors
!nuf
This commit is contained in:
parent
a1c805cc28
commit
ff86c83211
2 changed files with 17 additions and 1 deletions
|
@ -5,9 +5,13 @@ import MonkeyError from "../utils/error";
|
|||
import { incrementBadAuth } from "./rate-limit";
|
||||
import { NextFunction, Response } from "express";
|
||||
import { MonkeyResponse, handleMonkeyResponse } from "../utils/monkey-response";
|
||||
import { recordClientErrorByVersion } from "../utils/prometheus";
|
||||
import {
|
||||
recordClientErrorByVersion,
|
||||
recordServerErrorByVersion,
|
||||
} from "../utils/prometheus";
|
||||
import { isDevEnvironment } from "../utils/misc";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { version } from "../version";
|
||||
|
||||
type DBError = {
|
||||
_id: ObjectId;
|
||||
|
@ -61,6 +65,8 @@ async function errorHandlingMiddleware(
|
|||
monkeyResponse.status >= 500 &&
|
||||
monkeyResponse.status !== 503
|
||||
) {
|
||||
recordServerErrorByVersion(version);
|
||||
|
||||
const { uid, errorId } = monkeyResponse.data;
|
||||
|
||||
try {
|
||||
|
|
|
@ -189,6 +189,16 @@ export function recordClientErrorByVersion(version: string): void {
|
|||
clientErrorByVersion.inc({ version });
|
||||
}
|
||||
|
||||
const serverErrorByVersion = new Counter({
|
||||
name: "api_server_error_by_version",
|
||||
help: "Server versions which are generating 500 errors",
|
||||
labelNames: ["version"],
|
||||
});
|
||||
|
||||
export function recordServerErrorByVersion(version: string): void {
|
||||
serverErrorByVersion.inc({ version });
|
||||
}
|
||||
|
||||
const authTime = new Histogram({
|
||||
name: "api_request_auth_time",
|
||||
help: "Time spent authenticating",
|
||||
|
|
Loading…
Reference in a new issue