Skip to content

Commit

Permalink
add condition for not capturing static foles from next.js
Browse files Browse the repository at this point in the history
  • Loading branch information
chtushar committed May 16, 2024
1 parent 47c238d commit b0bdc6e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/clients/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,28 @@ export const instrumentNextjs = (
) as RequestMeta['match'];
const parsedPath = requestMetaMatch?.definition.pathname;

counter?.inc({
path: parsedPath !== '' ? parsedPath : '/',
method: req.method ?? 'GET',
status: res.statusCode?.toString() ?? '500'
// ...(store?.labels ?? {}) -> // TODO: Implement dynamic labels
});

histogram?.observe(
{
if (
parsedPath &&
!parsedPath.startsWith('/_next/static/') &&
!parsedPath.startsWith('/favicon.ico')
) {
counter?.inc({
path: parsedPath !== '' ? parsedPath : '/',
method: req.method ?? 'GET',
status: res.statusCode?.toString() ?? '500'
// ...(store?.labels ?? {}) -> // TODO: Implement dynamic labels
},
duration
);
});

histogram?.observe(
{
path: parsedPath !== '' ? parsedPath : '/',
method: req.method ?? 'GET',
status: res.statusCode?.toString() ?? '500'
// ...(store?.labels ?? {}) -> // TODO: Implement dynamic labels
},
duration
);
}

return result;
};
Expand Down

0 comments on commit b0bdc6e

Please sign in to comment.