Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { HTTP_TARGET } from '@sentry/conventions/attributes';
import { getClient, GLOBAL_OBJ, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, type Span, type SpanAttributes } from '@sentry/core';
import { isSentryRequestSpan } from '@sentry/opentelemetry';
import { HTTP_TARGET, HTTP_URL, URL_FULL } from '@sentry/conventions/attributes';
import {
getClient,
GLOBAL_OBJ,
isSentryRequestUrl,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
type Span,
type SpanAttributes,
} from '@sentry/core';
import { ATTR_NEXT_SPAN_TYPE } from '../nextSpanAttributes';
import { isPathnameUnderSentryTunnelRoute } from './tunnelPathnameMatch';
import { TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION } from '../span-attributes-with-logic-attached';
Expand Down Expand Up @@ -36,14 +42,25 @@ export function dropMiddlewareTunnelRequests(span: Span, attrs: SpanAttributes |

// Check if this is either a tunnel route request or a Sentry ingest request
const isTunnel = isTunnelRouteSpan(attrs || {});
const isSentry = isSentryRequestSpan(span);
const isSentry = isSentryRequestSpan(attrs || {});

if (isTunnel || isSentry) {
// Mark the span to be dropped
span.setAttribute(TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION, true);
}
}

function isSentryRequestSpan(attrs: SpanAttributes): boolean {
// `URL_FULL` is the new attribute, but we still support the old one, `HTTP_URL`, for now.
// eslint-disable-next-line typescript/no-deprecated
const httpUrl = attrs[HTTP_URL] || attrs[URL_FULL];

if (!httpUrl) {
return false;
}

return isSentryRequestUrl(httpUrl.toString(), getClient());
}
/**
* Checks if a span's HTTP target matches the tunnel route.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ vi.mock('@sentry/core', async requireActual => {
};
});

vi.mock('@sentry/opentelemetry', () => ({
isSentryRequestSpan: () => false,
}));

function createMockSpan(): { setAttribute: ReturnType<typeof vi.fn>; attributes: Record<string, unknown> } {
const attributes: Record<string, unknown> = {};
return {
Expand Down
2 changes: 0 additions & 2 deletions packages/opentelemetry/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export {
// Re-export this for backwards compatibility (this used to be a different implementation)
export { getDynamicSamplingContextFromSpan } from '@sentry/core';

export { isSentryRequestSpan } from './utils/isSentryRequest';

export { enhanceDscWithOpenTelemetryRootSpanName } from './utils/enhanceDscWithOpenTelemetryRootSpanName';

export { getActiveSpan } from './utils/getActiveSpan';
Expand Down
27 changes: 0 additions & 27 deletions packages/opentelemetry/src/utils/isSentryRequest.ts

This file was deleted.

Loading