From 64eea45ace9a396e195422232741e9ad64a526a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= <tadeuszs@element.io> Date: Thu, 10 Nov 2022 11:26:01 +0100 Subject: [PATCH] Fix matrix metrics handling (#869) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix matrix metrics handling * Add changelog Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> --- changelog.d/869.bugfix | 1 + src/metrics.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/869.bugfix diff --git a/changelog.d/869.bugfix b/changelog.d/869.bugfix new file mode 100644 index 0000000..e723503 --- /dev/null +++ b/changelog.d/869.bugfix @@ -0,0 +1 @@ +Fix a crash caused by processing metrics for Matrix events. \ No newline at end of file diff --git a/src/metrics.ts b/src/metrics.ts index 4be179a..2a64a24 100644 --- a/src/metrics.ts +++ b/src/metrics.ts @@ -69,7 +69,7 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics { private remoteRequest: Histogram<string>; private matrixRequest: Histogram<string>; private requestsInFlight: Map<string, number>; - private matrixRequestStatus: Map<string, "success"|"failed">; + private matrixRequestStatus: Map<string, "success"|"failed"> = new Map(); private httpServer: http.Server; private remoteMonthlyActiveUsers: Gauge<string>; private bridgeBlocked: Gauge<string>; @@ -116,7 +116,7 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics { this.matrixRequest = new Histogram({ help: "Histogram of processing durations of received Matrix messages", - labelNames: ["outcome"], + labelNames: ["outcome", "method"], name: "matrix_request_seconds", }); register.registerMetric(this.matrixRequest); @@ -208,7 +208,7 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics { this.matrixRequestStatus.delete(context.uniqueId); this.matrixRequest.observe({ method: context.functionName, - result: successFail, + outcome: successFail, }, timeMs); } -- GitLab