Skip to content

Sentry SDK adding 'sentry.drop_transaction` attribute to the trace of NextJs app instrumented with Open Telemetry #19169

Description

@elnatantorres

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

@sentry/nextjs

Framework Version

10.38.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

File:  sentry.server.config.ts 

import * as Sentry from '@sentry/nextjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  debug: false,
  integrations: [nodeProfilingIntegration()],
  sendDefaultPii: true,
  profilesSampleRate: 0.1,
  skipOpenTelemetrySetup: true,
});
File: instrumentation-client.ts

import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  debug: false,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 0.1,
  sendDefaultPii: true,
  ignoreErrors: [
    '_AutofillCallbackHandler',
    'Non-Error promise rejection captured',
    /^Unexpected token.*/,
    /^Cannot read properties of undefined (reading 'call')/,
    /attempted to hard navigate to the same URL/,
  ],
  integrations: [
    Sentry.replayIntegration({
      maskAllText: true,
      blockAllMedia: true,
    }),
  ],
  skipOpenTelemetrySetup: true,
});
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
File: sentry.edge.config.ts

import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  debug: false,
  sendDefaultPii: true,
  profilesSampleRate: 0.1,
  skipOpenTelemetrySetup: true, 
});
File: next.config.js

const { withSentryConfig } = require('@sentry/nextjs');

return withSentryConfig(config, {
  org: 'org',
  project: 'test-app',
  authToken: 'token',
  silent: true,
  tunnelRoute: '/monitoring',
  widenClientFileUpload: true,
  transpileClientSDK: false,
  hideSourceMaps: true,
  telemetry: false,
  sourcemaps: {
    deleteSourcemapsAfterUpload: true,
  },
  webpack: {
     automaticVercelMonitors: true,
     treeshake: {
        removeTracing: true,
     }
  },
  bundleSizeOptimizations: {
     excludeTracing: true,
   }
});
instrumentation.ts

import { PrismaInstrumentation } from '@prisma/instrumentation';
import { registerOTel } from '@vercel/otel';

export async function register() {
  const instrumentations = [];
    instrumentations.push(
      new PrismaInstrumentation({
        middleware: true,
      })
    );

    registerOTel({
      serviceName: 'test-app',
      instrumentationConfig: {
        fetch: {
          ignoreUrls: [/^https:\/\/telemetry.nextjs.org/],
        },
      },
      instrumentations,
    });

  if (
    process.env.NEXT_RUNTIME === 'nodejs'
  ) {
    await import('../sentry.server.config');
  }

  if (process.env.NEXT_RUNTIME === 'edge`) {
    await import('../sentry.edge.config');
  }
}
package.json

{
  "name": "test-app",
  "license": "MIT",
  "private": true,
  "engines": {
    "npm": "please-use-yarn",
    "node": "18.x || 20.x"
  },
  "packageManager": "yarn@4.6.0",
  "scripts": {
    "dev": "next dev"
  },
  "dependencies": {
    "@opentelemetry/api": "^1.8.0",
    "@opentelemetry/instrumentation": "^0.53.0",
    "@opentelemetry/sdk-logs": "^0.53.0",
    "@opentelemetry/sdk-trace-base": "^1.22.0",
    "@prisma/client": "5.22.0",
    "@prisma/instrumentation": "5.22.0",
    "@sentry/nextjs": "10.38.0",
    "@sentry/profiling-node": "10.38.0",
    "@vercel/edge-config": "^1.4.0",
    "@vercel/kv": "^1.0.1",
    "@vercel/otel": "1.14.0",
    "next": "14.2.25",
    "react": "18.2.0"
  },
  "devDependencies": {
    "@types/react": "18.2.0",
    "@types/react-dom": "18.2.0",
    "prisma": "5.22.0",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.9.2"
  }
}

I also have the variable __SENTRY_TRACING__=false set in the app.

Steps to Reproduce

By executing any route which uses prisma to query the database in the NextJs app, Open Telemetry will generate a trace for this transaction. In the span that starts with "executing api route (pages)" (which should be the second span), there should be an attribute like:

sentry.drop_transaction | true

Expected Result

Since I have disabled the tracing of Sentry in my app using these configs:

  • webpack.treeshake.removeTracing: true
  • webpack.bundleSizeOptimizations.excludeTracing: true
  • Env __SENTRY_TRACING__=false

I expected Sentry not to interfere in my Open Telemetry tracing instrumentation.

Actual Result

I see the attribute sentry.drop_transaction | true in my NextJs route span and I do not see in Grafana Tempo (backend which I export the traces to) the whole trace.

The presence of the Sentry attribute in the span is unexpected and I suspect that this is breaking the visualization of the traces in Grafana.

Additional Context

If you need further information to reproduce the problem, please contact me.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Activity

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions