Skip to content

Commit

Permalink
fix(node-experimental): Ignore outgoing Sentry requests (#8994)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mydea committed Sep 11, 2023
1 parent f63036b commit 9e39717
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/node-experimental/src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export class Http implements Integration {
this._unload = registerInstrumentations({
instrumentations: [
new HttpInstrumentation({
ignoreOutgoingRequestHook: request => {
const host = request.host || request.hostname;
return isSentryHost(host);
},

requireParentforOutgoingSpans: true,
requireParentforIncomingSpans: false,
requestHook: (span, req) => {
Expand Down Expand Up @@ -210,3 +215,11 @@ function getHttpUrl(attributes: Attributes): string | undefined {
const url = attributes[SemanticAttributes.HTTP_URL];
return typeof url === 'string' ? url : undefined;
}

/**
* Checks whether given host points to Sentry server
*/
function isSentryHost(host: string | undefined): boolean {
const dsn = getCurrentHub().getClient()?.getDsn();
return dsn && host ? host.includes(dsn.host) : false;
}

0 comments on commit 9e39717

Please sign in to comment.