Skip to content

Commit

Permalink
disable path and merge status codes in prom metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafeimMarg committed Sep 12, 2023
1 parent 88d67fa commit 3ffa1bd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/middlewares/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,25 @@ const queue = require('../queue');

const isEnabled = config.get('metrics:enabled');
const prometheusBundle = isEnabled ? promBundle({
includePath: true,
includePath: false,
includeMethod: true,
formatStatusCode: (status) => {
const statusCode = JSON.stringify(status);

if (statusCode >= 400 && statusCode < 500) {
return statusCode.toString();
}
if (statusCode >= 500) {
return '5xx';
}
if (statusCode >= 300 && statusCode < 400) {
return '3xx';
}
if (statusCode >= 200 && statusCode < 300) {
return statusCode.toString();
}
return statusCode;
},
autoregister: false, // Do not register the metrics endpoint
promClient: {
collectDefaultMetrics: {},
Expand Down

0 comments on commit 3ffa1bd

Please sign in to comment.