refactor(core): Expand Prometheus coverage to all routes (#10113)

This commit is contained in:
Iván Ovejero 2024-07-19 13:27:08 +02:00 committed by GitHub
parent 9ab29f2181
commit d35ee109ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 5 deletions

View file

@ -106,7 +106,16 @@ describe('PrometheusMetricsService', () => {
});
expect(app.use).toHaveBeenCalledWith(
['/rest/', '/webhook/', '/webhook-waiting/', '/form-waiting/', '/webhook-test/', '/api/'],
[
'/rest/',
'/api/',
'/webhook/',
'/webhook-waiting/',
'/webhook-test/',
'/form/',
'/form-waiting/',
'/form-test/',
],
expect.any(Function),
);
});

View file

@ -47,7 +47,7 @@ export class PrometheusMetricsService {
this.initN8nVersionMetric();
this.initCacheMetrics();
this.initEventBusMetrics();
this.initApiMetrics(app);
this.initRouteMetrics(app);
this.mountMetricsEndpoint(app);
}
@ -95,9 +95,9 @@ export class PrometheusMetricsService {
}
/**
* Set up metrics for API endpoints with `express-prom-bundle`
* Set up metrics for server routes with `express-prom-bundle`
*/
private initApiMetrics(app: express.Application) {
private initRouteMetrics(app: express.Application) {
if (!this.includes.metrics.api) return;
const metricsMiddleware = promBundle({
@ -109,7 +109,16 @@ export class PrometheusMetricsService {
});
app.use(
['/rest/', '/webhook/', '/webhook-waiting/', '/form-waiting/', '/webhook-test/', '/api/'],
[
'/rest/',
'/api/',
'/webhook/',
'/webhook-waiting/',
'/webhook-test/',
'/form/',
'/form-waiting/',
'/form-test/',
],
metricsMiddleware,
);
}