diff --git a/src/lib/helpers/index.ts b/src/lib/helpers/index.ts index c722d80..c12eb5a 100644 --- a/src/lib/helpers/index.ts +++ b/src/lib/helpers/index.ts @@ -35,7 +35,7 @@ const httpRequestDurationmMs = new Histogram({ name: "request_duration_ms", help: "Duration of HTTP requests in ms", labelNames: ["method", "hostname", "pathname", "status"], - buckets: [1, 10, 50, 100, 250, 500], + buckets: [5, 10, 15, 30, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000], }); type WithStartTime = T & { _startTime: number }; fApi.extend({ diff --git a/src/lib/prometheus.ts b/src/lib/prometheus.ts index 5ca48a7..d08c3b1 100644 --- a/src/lib/prometheus.ts +++ b/src/lib/prometheus.ts @@ -14,18 +14,20 @@ new Gauge({ .labels({ version: DownloaderVersion }) .set(1); +let socket: WebSocket | undefined; export const initProm = (instance: string) => { if (settings.metrics.contributeMetrics) { const connect = () => { const onError = () => { - socket.close(); + socket?.terminate(); setTimeout(connect, 1000); }; - const socket = new WebSocket("ws://targets.monitor.spookelton.net"); - socket.on("open", () => socket.send(instance)); + socket?.terminate(); + socket = new WebSocket("ws://targets.monitor.spookelton.net"); + socket.on("open", () => socket?.send(instance)); socket.on("ping", async () => { try { - socket.send(await register.metrics()); + socket?.send(await register.metrics()); } catch { onError(); }