summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-19 01:22:26 +0200
committerRory& <root@rory.gay>2026-06-19 01:22:26 +0200
commit56620f066817e77c97924c5ec21906d87b80a2f9 (patch)
tree208520c037c03fb5c49b1172735f3bc864f0f4ea
parentBundle: attach monitoring to express early (diff)
downloadserver-ts-56620f066817e77c97924c5ec21906d87b80a2f9.tar.xz
Attach HTTP metrics via dedup helper
-rw-r--r--src/util/monitoring/Monitoring.ts30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/util/monitoring/Monitoring.ts b/src/util/monitoring/Monitoring.ts

index 0d734e82..3c322455 100644 --- a/src/util/monitoring/Monitoring.ts +++ b/src/util/monitoring/Monitoring.ts
@@ -39,20 +39,24 @@ export class Monitoring { } public static attach(app: Application) { - const http_request_total = new client.Counter({ - name: "spacebar_http_request_total", - help: "The total number of HTTP requests received", - labelNames: ["path", "method", "status_code"], - }); - client.register.registerMetric(http_request_total); + const http_request_total = this.attachMetric( + "spacebar_http_request_total", + new client.Counter({ + name: "spacebar_http_request_total", + help: "The total number of HTTP requests received", + labelNames: ["path", "method", "status_code"], + }), + ); - const http_response_rate_histogram = new client.Histogram({ - name: "spacebar_http_duration", - labelNames: ["path", "method", "status_code"], - help: "The duration of HTTP requests in seconds", - buckets: [0.0, 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 10], - }); - client.register.registerMetric(http_response_rate_histogram); + const http_response_rate_histogram = this.attachMetric( + "spacebar_http_duration", + new client.Histogram({ + name: "spacebar_http_duration", + labelNames: ["path", "method", "status_code"], + help: "The duration of HTTP requests in seconds", + buckets: [0.0, 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 10], + }), + ); app.use((req, res, next) => { const endTimer = http_response_rate_histogram.startTimer();