*/Server.ts: Handle metrics requests

This commit is contained in:
Rory&
2026-05-20 14:06:19 +02:00
parent 4a9c6cacc5
commit e2da753c2d
3 changed files with 8 additions and 0 deletions
+1
View File
@@ -53,6 +53,7 @@ export class SpacebarServer extends Server {
async start() {
await Monitoring.init();
Monitoring.attach(this.app);
await initDatabase();
await Config.init();
await initEvent();
+1
View File
@@ -37,6 +37,7 @@ export class CDNServer extends Server {
async start() {
await Monitoring.init();
Monitoring.attach(this.app);
await initDatabase();
await Config.init();
+6
View File
@@ -18,6 +18,7 @@
import * as client from "prom-client";
import { Router } from "express";
import http, { IncomingMessage, ServerResponse } from "node:http";
export class Monitoring {
static isInitialised = false;
@@ -35,4 +36,9 @@ export class Monitoring {
res.send(metrics);
});
}
static async handleRawRequest(req: IncomingMessage, res: ServerResponse) {
const metrics = await client.register.metrics();
res.setHeader("Content-Type", client.register.contentType).writeHead(200).end(metrics);
}
}