Skip to content

[NextJS] Suppress instrumentation warningΒ #16815

@eseyfert

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?

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions