Skip to content

Next.js instrumentation doesn't honour usePathAsTransactionName config var #3072

Open
@trentm

Description

@trentm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions