Skip to content

Commit

Permalink
🐛 fix middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ponomarevkonst authored and XanderD99 committed Jun 29, 2023
1 parent c4cb603 commit efdb496
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/middlewares/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ module.exports = {
metrics: ({ strapi }) => {
const { config, service } = strapi.plugin(plugin_id);
const metrics = service('metrics');
const isHTTPMetricEnabled = config('enabledMetrics.http');

return async (ctx, next) => {
const requestEnd = metrics.get(metricNames.HTTP.requestDuration)?.startTimer({ method: ctx.method });
await next();

if (!isHTTPMetricEnabled) return;
ctx.res.once('finish', () => {
if (ctx._matchedRoute === `${strapi.config.api.rest.prefix}/metrics`) return;
let path = `${config('fullURL') ? ctx.url.split('?')[0] : ctx._matchedRoute || '/'}`;
Expand Down

0 comments on commit efdb496

Please sign in to comment.