Skip to content

Commit 7325abb

Browse files
authored
fix(node): Use suppressTracing to avoid capturing otel spans (#11288)
I leave the other checks (e.g. in http integration) in there, for now (where we check if the url is sentry URL), but this should ensure we are also not picked up by any other OTEL instrumentation etc.
1 parent c889bd2 commit 7325abb

File tree

1 file changed

+7
-3
lines changed
  • packages/node-experimental/src/transports

1 file changed

+7
-3
lines changed

packages/node-experimental/src/transports/http.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as http from 'node:http';
22
import * as https from 'node:https';
33
import { Readable } from 'stream';
44
import { createGzip } from 'zlib';
5+
import { context } from '@opentelemetry/api';
6+
import { suppressTracing } from '@opentelemetry/core';
57
import { createTransport } from '@sentry/core';
68
import type {
79
BaseTransportOptions,
@@ -12,7 +14,6 @@ import type {
1214
} from '@sentry/types';
1315
import { consoleSandbox } from '@sentry/utils';
1416
import { HttpsProxyAgent } from '../proxy';
15-
1617
import type { HTTPModule } from './http-module';
1718

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

83-
const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
84-
return createTransport(options, requestExecutor);
84+
// This ensures we do not generate any spans in OpenTelemetry for the transport
85+
return context.with(suppressTracing(context.active()), () => {
86+
const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
87+
return createTransport(options, requestExecutor);
88+
});
8589
}
8690

8791
/**

0 commit comments

Comments
 (0)