clear metrics
All checks were successful
Build and push image for doorman-homeassistant / docker (push) Successful in 28s
Build and push Doorman UI / API / docker (push) Successful in 1m31s
Build and push image for doorman-homeassistant / deploy-gitainer (push) Successful in 5s

This commit is contained in:
Martin Dimitrov 2024-12-24 11:37:55 -08:00
parent 070c5634cd
commit e31451bae5

View File

@ -1,5 +1,5 @@
import { ServerlessCallback, ServerlessFunctionSignature } from "@twilio-labs/serverless-runtime-types/types";
import { PrometheusContentType, Registry, Pushgateway, Summary, Counter } from "prom-client";
import { PrometheusContentType, Registry, Pushgateway, Summary, Counter, register } from "prom-client";
import { DoormanLambdaContext } from "./DoormanHandlerContext";
import { shouldBlockRequest } from "../utils/blockUserAgent";
import { RequestOptions } from "https";
@ -33,6 +33,9 @@ export function withMetrics<T extends DoormanLambdaContext, U extends BaseEvent>
handler: DoormanLambda<T, U>
): ServerlessFunctionSignature<T, U> {
return async (context, event, callback) => {
console.log("[CommonHandler] clearing old metrics");
register.clear();
console.log("[CommonHandler] creating metrics registry");
const metricsRegistry = new Registry();
const requestOptions: RequestOptions = {
@ -127,6 +130,8 @@ export function withMetrics<T extends DoormanLambdaContext, U extends BaseEvent>
console.error("[CommonHandler] failed to push metrics, quietly discarding them", e);
}
clearTimeout(metricsTimeout);
callback(...result);
};