Skip to content

Commit 5bfca44

Browse files
committed
refactor: keep version label on new rest api metric
1 parent 6b64dd4 commit 5bfca44

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

apps/meteor/app/api/server/middlewares/metrics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ export const metricsMiddleware =
4141
const histogramLabels = {
4242
status: c.res.status,
4343
method: method.toLowerCase(),
44+
version: api.version,
4445
entrypoint: basePathRegex && entrypoint.startsWith('method.call') ? decodeURIComponent(path.replace(basePathRegex, '')) : entrypoint,
4546
};
4647

4748
rocketchatRestApiEnd({
4849
...histogramLabels,
49-
version: api.version,
5050
...(settings.get('Prometheus_API_User_Agent') && { user_agent: c.req.header('user-agent') }),
5151
});
52+
5253
rocketchatRestApiHistEnd(histogramLabels);
5354

5455
const contentLength = parseInt(c.res.headers.get('content-length') || '0', 10);

apps/meteor/app/metrics/server/lib/metrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const metrics = {
8282
rocketchatRestApiSeconds: new client.Histogram({
8383
name: 'rocketchat_rest_api_seconds',
8484
help: 'histogram of rocketchat rest api count and time in seconds',
85-
labelNames: ['method', 'entrypoint', 'status'],
85+
labelNames: ['method', 'entrypoint', 'status', 'version'],
8686
buckets: latencyBuckets,
8787
}),
8888
rocketchatRestApiResponseSizeBytes: new client.Histogram({

0 commit comments

Comments
 (0)