Skip to content

Commit b2948e8

Browse files
authored
fix(tracing): Don't consider tracing origins when creating spans (#6039)
1 parent 6c8d6c3 commit b2948e8

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

packages/tracing/src/browser/request.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
BAGGAGE_HEADER_NAME,
66
dynamicSamplingContextToSentryBaggageHeader,
77
isInstanceOf,
8-
isMatchingPattern,
98
} from '@sentry/utils';
109

1110
import { getActiveTransaction, hasTracingEnabled } from '../utils';
@@ -104,34 +103,13 @@ export const defaultRequestInstrumentationOptions: RequestInstrumentationOptions
104103
/** Registers span creators for xhr and fetch requests */
105104
export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumentationOptions>): void {
106105
// eslint-disable-next-line @typescript-eslint/unbound-method
107-
const { traceFetch, traceXHR, tracingOrigins, shouldCreateSpanForRequest } = {
106+
const { traceFetch, traceXHR, shouldCreateSpanForRequest } = {
108107
...defaultRequestInstrumentationOptions,
109108
..._options,
110109
};
111110

112-
// We should cache url -> decision so that we don't have to compute
113-
// regexp everytime we create a request.
114-
const urlMap: Record<string, boolean> = {};
115-
116-
const defaultShouldCreateSpan = (url: string): boolean => {
117-
if (urlMap[url]) {
118-
return urlMap[url];
119-
}
120-
const origins = tracingOrigins;
121-
urlMap[url] =
122-
origins.some((origin: string | RegExp) => isMatchingPattern(url, origin)) &&
123-
!isMatchingPattern(url, 'sentry_key');
124-
return urlMap[url];
125-
};
126-
127-
// We want that our users don't have to re-implement shouldCreateSpanForRequest themselves
128-
// That's why we filter out already unwanted Spans from tracingOrigins
129-
let shouldCreateSpan = defaultShouldCreateSpan;
130-
if (typeof shouldCreateSpanForRequest === 'function') {
131-
shouldCreateSpan = (url: string) => {
132-
return defaultShouldCreateSpan(url) && shouldCreateSpanForRequest(url);
133-
};
134-
}
111+
const shouldCreateSpan =
112+
typeof shouldCreateSpanForRequest === 'function' ? shouldCreateSpanForRequest : (_: string) => true;
135113

136114
const spans: Record<string, Span> = {};
137115

0 commit comments

Comments
 (0)