Skip to content

autoInstrumentMiddleware doesn't seem to work #9285

@seanparmelee

Description

@seanparmelee

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.72.0

Framework Version

Next 13.4.19

Link to Sentry event

No response

SDK Setup

For this issue, I think what we're passing into withSentryConfig is more relevant:

const sentryConfig = {
  autoInstrumentMiddleware: false,
  hideSourceMaps: true
};

const nextConfigWithSentry = withSentryConfig(
  nextConfig,
  sentryWebpackPluginOptions,
  sentryConfig,
);

But just in case, here's what the sentry.edge.config.ts file looks like:

Sentry.init({
  enabled: process.env.NODE_ENV === 'production',
  dsn: SENTRY_DSN,
  environment: process.env.SENTRY_ENVIRONMENT,
  tracesSampleRate: 1,
});

Steps to Reproduce

Pre-req: A Next.js application that has middleware

  1. As per the docs, add the following to opt out of auto instrumentation of middleware:
const nextConfig = {
  sentry: {
    autoInstrumentMiddleware: false,
  },
};
  1. Start the application and perform the necessary steps for the middleware to be triggered
  2. Check Sentry to see if the request that was handled by the middleware shows up in the performance and/or discover sections.

Expected Result

Since auto instrumentation is disabled, I don't expect to see any middleware transactions in Sentry.

Actual Result

We are still seeing middleware entries in Sentry
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions