elastic / elastic/apm-agent-nodejs

Next.js instrumentation doesn't honour `usePathAsTransactionName` config var

Open
#3,072 1 comment 0 reactions 0 assignees View on GitHub
8.8-candidate agent-nodejs
Dominant language
JavaScript
Stars
594
Forks
244
Avg merge
1d 8h
Merged PRs (30d)
16

Description

As discussed at https://discuss.elastic.co/t/next-js-and-dynamic-routes/321302 the current Next.js instrumentation that sets the `transaction.name` for a Dynamic Route does not honour the `usePathAsTransactionName: true` config var. That means that a request `GET /a-dynamic-route/42` to this dynamic route https://github.com/elastic/apm-agent-nodejs/blob/main/test/instrumentation/modules/next/a-nextjs-app/pages/a-dynamic-page/%5Bnum%5D.js results in `transaction.name = 'GET /a-dynamic-route/[num]` even if `usePathAsTransactionName: true`.

Note that there is also naming of the `Next.js _data/route ...` transactions for possibly dynamic routes -- e.g. "Next.js _next/data route /a-dynamic-page/[num]". However, I don't think those should honour `usePathAsTransactionName`. At least not without user feedback.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.