Skip to content

Commit 9e39717

Browse files
authored
fix(node-experimental): Ignore outgoing Sentry requests (#8994)
We do filter these out in the span processor, but we can avoid all this work by not even generating OTEL spans at all for outgoing Sentry requests.
1 parent f63036b commit 9e39717

File tree

1 file changed

+13
-0
lines changed
  • packages/node-experimental/src/integrations

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ export class Http implements Integration {
9393
this._unload = registerInstrumentations({
9494
instrumentations: [
9595
new HttpInstrumentation({
96+
ignoreOutgoingRequestHook: request => {
97+
const host = request.host || request.hostname;
98+
return isSentryHost(host);
99+
},
100+
96101
requireParentforOutgoingSpans: true,
97102
requireParentforIncomingSpans: false,
98103
requestHook: (span, req) => {
@@ -210,3 +215,11 @@ function getHttpUrl(attributes: Attributes): string | undefined {
210215
const url = attributes[SemanticAttributes.HTTP_URL];
211216
return typeof url === 'string' ? url : undefined;
212217
}
218+
219+
/**
220+
* Checks whether given host points to Sentry server
221+
*/
222+
function isSentryHost(host: string | undefined): boolean {
223+
const dsn = getCurrentHub().getClient()?.getDsn();
224+
return dsn && host ? host.includes(dsn.host) : false;
225+
}

0 commit comments

Comments
 (0)