Skip to content

Commit def5490

Browse files
authored
feat: Simplify shouldCreateSpanForRequest (#2867)
1 parent 89e11d1 commit def5490

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/tracing/src/browser/request.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,14 @@ export function registerRequestInstrumentation(_options?: Partial<RequestInstrum
100100
return urlMap[url];
101101
};
102102

103-
const shouldCreateSpan = shouldCreateSpanForRequest || defaultShouldCreateSpan;
103+
// We want that our users don't have to re-implement shouldCreateSpanForRequest themselves
104+
// That's why we filter out already unwanted Spans from tracingOrigins
105+
let shouldCreateSpan = defaultShouldCreateSpan;
106+
if (typeof shouldCreateSpanForRequest === 'function') {
107+
shouldCreateSpan = (url: string) => {
108+
return defaultShouldCreateSpan(url) && shouldCreateSpanForRequest(url);
109+
};
110+
}
104111

105112
const spans: Record<string, Span> = {};
106113

0 commit comments

Comments
 (0)