mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
Add metricsApp option
Lets you supply an additional express app on which to mount the metrics endpoint
This commit is contained in:
10
src/index.js
10
src/index.js
@@ -68,7 +68,8 @@ function main(opts) {
|
||||
formatStatusCode: main.normalizeStatusCode,
|
||||
metricType: 'histogram',
|
||||
promClient: {},
|
||||
promRegistry: promClient.register
|
||||
promRegistry: promClient.register,
|
||||
metricsApp: null,
|
||||
}, opts
|
||||
);
|
||||
|
||||
@@ -204,6 +205,13 @@ function main(opts) {
|
||||
next();
|
||||
};
|
||||
|
||||
if (opts.metricsApp) {
|
||||
opts.metricsApp.get(opts.metricsPath || '/metrics', async (req, res, next) => {
|
||||
res.set('Content-Type', opts.promRegistry.contentType);
|
||||
return res.end(await opts.promRegistry.metrics());
|
||||
});
|
||||
}
|
||||
|
||||
middleware.metrics = metrics;
|
||||
middleware.promClient = promClient;
|
||||
middleware.metricsMiddleware = metricsMiddleware;
|
||||
|
||||
Reference in New Issue
Block a user