Skip to content

Sentry SDK interferes with OpenTelemetry fetch spans despite skipOpenTelemetrySetup: true #17581

@JandaTheMan

Description

@JandaTheMan

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

^10.11.0

Framework Version

Next 15.5.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
        dsn: sentryDSN,
        environment: environment,
        release: release,
        skipOpenTelemetrySetup: true, 
        integrations: [
            Sentry.httpIntegration({spans: false}),
        ],
    });

Along with:

context.setGlobalContextManager(new AsyncLocalStorageContextManager());

const traceExporter = new OTLPTraceExporter();
const batchSpanProcessor = new SimpleSpanProcessor(traceExporter);

const sdk = new NodeSDK({
    spanProcessors: [batchSpanProcessor],
    textMapPropagator: new W3CTraceContextPropagator(),
    instrumentations: [
        getNodeAutoInstrumentations({
            '@opentelemetry/instrumentation-http': {
                enabled: true
            },
            '@opentelemetry/instrumentation-dns': {
                enabled: false
            }
        }),
    ],
});

// Start the OpenTelemetry SDK
sdk.start();

// Ensure proper shutdown on process exit
process.on('SIGTERM', () => {
    sdk
        .shutdown()
        .then(() => console.log('OpenTelemetry SDK shut down successfully'))
        .catch((error: Error) => console.error('Error shutting down OpenTelemetry SDK:', error))
        .finally(() => process.exit(0));
});

Initialised in nextjs as follows:

export const register = async () => {
    if (process.env.NEXT_RUNTIME === 'nodejs') {
        await import('../instrumentation.node');
        await import('../sentry.server.config');
    }
};

export const onRequestError = Sentry.captureRequestError;

Steps to Reproduce

Complete reproduction repository: https://github.com/JandaTheMan/Sentry-OpenTelemetry-Issue-Reproduction

Setup reproduction environment:

  • Clone the reproduction repository above
  • Install dependencies: npm install
  • Start observability stack: npm run observability:up
    Test without Sentry (baseline):
  • Ensure SENTRY_DSN is NOT set in .env
  • Start app: npm run dev
  • Visit http://localhost:3000/
  • Check traces in Grafana at http://localhost:3003/explore
    Test with Sentry (issue reproduction):
  • Set SENTRY_DSN=your-dsn-here in .env file
  • Restart app: npm run dev
  • Visit http://localhost:3000/
  • Check traces in Grafana at http://localhost:3003/explore
    Note: The repository includes a complete observability stack (OpenTelemetry Collector + Tempo + Grafana) and detailed instructions for easy reproduction.

A complete guide for reproduction is included in the repository.

Expected Result

Fetch node traces are included the same way when sentry sdk is not initialised:

Image

Actual Result

Fetch node traces are not included the same way when sentry sdk is not initialised:

Image

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions