|
1 | | -import { HTTP_TARGET } from '@sentry/conventions/attributes'; |
2 | | -import { getClient, GLOBAL_OBJ, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, type Span, type SpanAttributes } from '@sentry/core'; |
3 | | -import { isSentryRequestSpan } from '@sentry/opentelemetry'; |
| 1 | +import { HTTP_TARGET, HTTP_URL, URL_FULL } from '@sentry/conventions/attributes'; |
| 2 | +import { |
| 3 | + getClient, |
| 4 | + GLOBAL_OBJ, |
| 5 | + isSentryRequestUrl, |
| 6 | + SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, |
| 7 | + type Span, |
| 8 | + type SpanAttributes, |
| 9 | +} from '@sentry/core'; |
4 | 10 | import { ATTR_NEXT_SPAN_TYPE } from '../nextSpanAttributes'; |
5 | 11 | import { isPathnameUnderSentryTunnelRoute } from './tunnelPathnameMatch'; |
6 | 12 | import { TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION } from '../span-attributes-with-logic-attached'; |
@@ -36,14 +42,25 @@ export function dropMiddlewareTunnelRequests(span: Span, attrs: SpanAttributes | |
36 | 42 |
|
37 | 43 | // Check if this is either a tunnel route request or a Sentry ingest request |
38 | 44 | const isTunnel = isTunnelRouteSpan(attrs || {}); |
39 | | - const isSentry = isSentryRequestSpan(span); |
| 45 | + const isSentry = isSentryRequestSpan(attrs || {}); |
40 | 46 |
|
41 | 47 | if (isTunnel || isSentry) { |
42 | 48 | // Mark the span to be dropped |
43 | 49 | span.setAttribute(TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION, true); |
44 | 50 | } |
45 | 51 | } |
46 | 52 |
|
| 53 | +function isSentryRequestSpan(attrs: SpanAttributes): boolean { |
| 54 | + // `URL_FULL` is the new attribute, but we still support the old one, `HTTP_URL`, for now. |
| 55 | + // eslint-disable-next-line typescript/no-deprecated |
| 56 | + const httpUrl = attrs[HTTP_URL] || attrs[URL_FULL]; |
| 57 | + |
| 58 | + if (!httpUrl) { |
| 59 | + return false; |
| 60 | + } |
| 61 | + |
| 62 | + return isSentryRequestUrl(httpUrl.toString(), getClient()); |
| 63 | +} |
47 | 64 | /** |
48 | 65 | * Checks if a span's HTTP target matches the tunnel route. |
49 | 66 | */ |
|
0 commit comments