From c28ecd8b1775c7ae38df14b811bfdd26a465d901 Mon Sep 17 00:00:00 2001 From: Raggi <35541698+ragrag@users.noreply.github.com> Date: Fri, 5 Apr 2024 23:43:37 +0200 Subject: [PATCH] Revert "feat: add collectExtraMetrics" This reverts commit e1f9664fb60116181b6c774eb18327677c19e994. --- src/lib/MonitoringServer.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/lib/MonitoringServer.ts b/src/lib/MonitoringServer.ts index 82e06fc..48a08f6 100644 --- a/src/lib/MonitoringServer.ts +++ b/src/lib/MonitoringServer.ts @@ -1,4 +1,4 @@ -import fastify, { FastifyInstance, FastifyRequest, FastifyReply } from "fastify"; +import fastify, { FastifyInstance } from "fastify"; import type { MeteringRecorder } from "./MeteringRecorder"; import type { Loggerlike } from "./types"; @@ -7,27 +7,18 @@ type MonioringMiddlewareDependencies = { server: FastifyInstance; meteringRecorder: MeteringRecorder; enableDefaultMetrics?: boolean; - collectExtraMetrics?: () => Promise; }; const assignMonitoringRoutes = ({ server, meteringRecorder, enableDefaultMetrics, - collectExtraMetrics, }: MonioringMiddlewareDependencies) => { if (enableDefaultMetrics) { meteringRecorder.enableDefaultMetrics(); } - server.get("/metrics", async (_: FastifyRequest, reply: FastifyReply) => { - const metrics = await meteringRecorder.getPrometheusResponse(); - if (collectExtraMetrics) { - const extraMetrics = await collectExtraMetrics(); - return reply.type("text/plain").send(metrics + extraMetrics); - } - return reply.type("text/plain").send(metrics); - }); + server.get("/metrics", async () => meteringRecorder.getPrometheusResponse()); }; export class MonitoringServer { @@ -40,7 +31,6 @@ export class MonitoringServer { private logger: Loggerlike, private enableDefaultMetrics = true, private port = 9500, - private collectExtraMetrics: () => Promise, ) {} public async start(): Promise { @@ -49,7 +39,6 @@ export class MonitoringServer { server: this.server, meteringRecorder: this.recorder, enableDefaultMetrics: this.enableDefaultMetrics, - collectExtraMetrics: this.collectExtraMetrics, }); await new Promise((resolve, reject) =>