Skip to content

Commit 603d460

Browse files
committed
fix(node): Use suppressTracing to avoid capturing otel spans
1 parent 4e4f1da commit 603d460

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

+7-3
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)