Skip to content

[NextJS] Suppress instrumentation warning #16815

Closed

Description

@eseyfert

Problem Statement

Hey there! 👋

We use @opentelemetry for instrumentation in our NextJS app, meaning we have no need for the built-in Sentry tracing.

I have disabled it for both the client and server config using tracesSampleRate: 0.
In the instrumentation-client.ts file, I have omitted the export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; line as we have no need for it.

Now we get this warning whenever the app is built:

[@sentry/nextjs] ACTION REQUIRED: To instrument navigations, the Sentry SDK requires you to export an `onRouterTransitionStart` hook from your `instrumentation-client.(js|ts)` file. You can do so by adding `export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;` to the file.

It would be great to have a mechanism to suppress this warning as it just produces noise in our case.
Thanks for taking the time to read this. 🙂

PS: If I completely misunderstood the point behind the onRouterTransitionStart = Sentry.captureRouterTransitionStart; line, I would love to know.

Solution Brainstorm

I could see a few ways to achieve this:

  1. Provide a Sentry.init() setting to modify this behavior?
Sentry.init({
   suppressInstrumentationWarning: boolean
});
  1. If tracesSampleRate is set to 0 in the instrumentation-client.ts file, don't print the warning?

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 4, 2025
  2. self-assigned this
    on Jul 7, 2025
  3. chargome commented on Jul 7, 2025

    @chargome
    Member

    Hey @eseyfert thanks for writing in! We need captureRouterTransitionStart for instrumenting client-side routing but if you provide your own setup it def makes sense to not show this warning – I'll add a flag for disabling the warning!

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 7, 2025
  5. mydea commented on Jul 7, 2025

    @mydea
    Member

    Also a side note, setting tracesSampleRate: 0 does not disable tracing! you should not set this attribute at all, instead. We should likely document this better, I added an issue here: getsentry/sentry-docs#14267

    TLDR you should likely use __SENTRY_TRACING__ to fully disable tracing code: https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/

  6. eseyfert commented on Jul 7, 2025

    @eseyfert
    Author

    Thank you so much for the quick answers and insights! 💯

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 7, 2025
  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 7, 2025
  9. github-actions commented on Jul 9, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #16823, which was included in the 9.36.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions