Skip to content

Commit

Permalink
Fix matrix metrics handling (#869)
Browse files Browse the repository at this point in the history
* Fix matrix metrics handling

* Add changelog

Co-authored-by: Tadeusz Sośnierz <[email protected]>
  • Loading branch information
Tadeusz Sośnierz and tadzik authored Nov 10, 2022
1 parent d582bc3 commit 64eea45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/869.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a crash caused by processing metrics for Matrix events.
6 changes: 3 additions & 3 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 64eea45

Please sign in to comment.