Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(otel): Ignore outgoing Sentry HTTP requests from otel integration (
- Loading branch information
Showing
4 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/opentelemetry-node/src/utils/is-sentry-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Span as OtelSpan } from '@opentelemetry/sdk-trace-base'; | ||
import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; | ||
import { getCurrentHub } from '@sentry/core'; | ||
|
||
/** | ||
* | ||
* @param otelSpan Checks wheter a given OTEL Span is an http request to sentry. | ||
* @returns boolean | ||
*/ | ||
export function isSentryRequestSpan(otelSpan: OtelSpan): boolean { | ||
const { attributes } = otelSpan; | ||
|
||
const httpUrl = attributes[SemanticAttributes.HTTP_URL]; | ||
|
||
if (!httpUrl) { | ||
return false; | ||
} | ||
|
||
return isSentryRequestUrl(httpUrl.toString()); | ||
} | ||
|
||
/** | ||
* Checks whether given url points to Sentry server | ||
* @param url url to verify | ||
*/ | ||
function isSentryRequestUrl(url: string): boolean { | ||
const dsn = getCurrentHub().getClient()?.getDsn(); | ||
return dsn ? url.includes(dsn.host) : false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters