Skip to content

fix(node): Use suppressTracing to avoid capturing otel spans #11288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/node-experimental/src/transports/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as http from 'node:http';
import * as https from 'node:https';
import { Readable } from 'stream';
import { createGzip } from 'zlib';
import { context } from '@opentelemetry/api';
import { suppressTracing } from '@opentelemetry/core';
import { createTransport } from '@sentry/core';
import type {
BaseTransportOptions,
Expand All @@ -12,7 +14,6 @@ import type {
} from '@sentry/types';
import { consoleSandbox } from '@sentry/utils';
import { HttpsProxyAgent } from '../proxy';

import type { HTTPModule } from './http-module';

export interface NodeTransportOptions extends BaseTransportOptions {
Expand Down Expand Up @@ -80,8 +81,11 @@ export function makeNodeTransport(options: NodeTransportOptions): Transport {
? (new HttpsProxyAgent(proxy) as http.Agent)
: new nativeHttpModule.Agent({ keepAlive, maxSockets: 30, timeout: 2000 });

const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
return createTransport(options, requestExecutor);
// This ensures we do not generate any spans in OpenTelemetry for the transport
return context.with(suppressTracing(context.active()), () => {
const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
return createTransport(options, requestExecutor);
});
}

/**
Expand Down