2021-06-24 10:09:10 +02:00
|
|
|
import { App } from "../Server/sifrr.server";
|
|
|
|
import { HttpRequest, HttpResponse } from "uWebSockets.js";
|
2021-12-23 15:27:17 +01:00
|
|
|
import { register, collectDefaultMetrics } from "prom-client";
|
2020-11-13 18:00:22 +01:00
|
|
|
|
|
|
|
export class PrometheusController {
|
|
|
|
constructor(private App: App) {
|
|
|
|
collectDefaultMetrics({
|
|
|
|
gcDurationBuckets: [0.001, 0.01, 0.1, 1, 2, 5], // These are the default buckets.
|
|
|
|
});
|
|
|
|
|
|
|
|
this.App.get("/metrics", this.metrics.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
private metrics(res: HttpResponse, req: HttpRequest): void {
|
2021-06-24 10:09:10 +02:00
|
|
|
res.writeHeader("Content-Type", register.contentType);
|
2020-11-13 18:00:22 +01:00
|
|
|
res.end(register.metrics());
|
|
|
|
}
|
|
|
|
}
|