@@ -5,7 +5,7 @@ import { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan';
5
5
import type { FetchBreadcrumbHint , HandlerDataFetch , Span , SpanOrigin } from './types-hoist' ;
6
6
import { SENTRY_BAGGAGE_KEY_PREFIX } from './utils-hoist/baggage' ;
7
7
import { isInstanceOf } from './utils-hoist/is' ;
8
- import { parseUrl , stripUrlQueryAndFragment } from './utils-hoist/url' ;
8
+ import { parseStringToURL , stripUrlQueryAndFragment } from './utils-hoist/url' ;
9
9
import { hasSpansEnabled } from './utils/hasSpansEnabled' ;
10
10
import { getActiveSpan } from './utils/spanUtils' ;
11
11
import { getTraceData } from './utils/traceData' ;
@@ -53,8 +53,7 @@ export function instrumentFetchRequest(
53
53
return undefined ;
54
54
}
55
55
56
- const fullUrl = getFullURL ( url ) ;
57
- const parsedUrl = fullUrl ? parseUrl ( fullUrl ) : parseUrl ( url ) ;
56
+ const parsedUrl = parseStringToURL ( url ) ;
58
57
59
58
const hasParent = ! ! getActiveSpan ( ) ;
60
59
@@ -66,12 +65,12 @@ export function instrumentFetchRequest(
66
65
url,
67
66
type : 'fetch' ,
68
67
'http.method' : method ,
69
- 'http.url' : fullUrl ,
70
- 'server.address' : parsedUrl ?. host ,
68
+ 'http.url' : parsedUrl ?. href || url ,
71
69
[ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : spanOrigin ,
72
70
[ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'http.client' ,
73
- ...( parsedUrl ?. search && { 'http.query' : parsedUrl ?. search } ) ,
74
- ...( parsedUrl ?. hash && { 'http.fragment' : parsedUrl ?. hash } ) ,
71
+ ...( parsedUrl ?. host && { 'server.address' : parsedUrl . host } ) ,
72
+ ...( parsedUrl ?. search && { 'http.query' : parsedUrl . search } ) ,
73
+ ...( parsedUrl ?. hash && { 'http.fragment' : parsedUrl . hash } ) ,
75
74
} ,
76
75
} )
77
76
: new SentryNonRecordingSpan ( ) ;
@@ -215,15 +214,6 @@ function _addTracingHeadersToFetchRequest(
215
214
}
216
215
}
217
216
218
- function getFullURL ( url : string ) : string | undefined {
219
- try {
220
- const parsed = new URL ( url ) ;
221
- return parsed . href ;
222
- } catch {
223
- return undefined ;
224
- }
225
- }
226
-
227
217
function endSpan ( span : Span , handlerData : HandlerDataFetch ) : void {
228
218
if ( handlerData . response ) {
229
219
setHttpStatus ( span , handlerData . response . status ) ;
0 commit comments