@@ -192,13 +192,28 @@ function _createWrappedRequestMethodFactory(
192
192
193
193
const scope = getCurrentHub ( ) . getScope ( ) ;
194
194
195
+ const spanData : Record < string , string > = {
196
+ url : requestUrl ,
197
+ method : requestOptions . method || 'GET' ,
198
+ } ;
199
+ if ( requestOptions . hash ) {
200
+ // strip leading "#"
201
+ spanData [ 'http.fragment' ] = requestOptions . hash . substring ( 1 ) ;
202
+ }
203
+ if ( requestOptions . search ) {
204
+ // strip leading "?"
205
+ spanData [ 'http.query' ] = requestOptions . search . substring ( 1 ) ;
206
+ }
207
+
208
+ // TODO potential breaking change... shouldCreateSpanForRequest no longer has access to query + fragment, is that a problem?
195
209
if ( scope && tracingOptions && shouldCreateSpan ( requestUrl ) ) {
196
210
parentSpan = scope . getSpan ( ) ;
197
211
198
212
if ( parentSpan ) {
199
213
requestSpan = parentSpan . startChild ( {
200
- description : `${ requestOptions . method || 'GET' } ${ requestUrl } ` ,
214
+ description : `${ spanData . method } ${ spanData . url } ` ,
201
215
op : 'http.client' ,
216
+ data : spanData ,
202
217
} ) ;
203
218
204
219
if ( shouldAttachTraceData ( requestUrl ) ) {
@@ -253,7 +268,7 @@ function _createWrappedRequestMethodFactory(
253
268
// eslint-disable-next-line @typescript-eslint/no-this-alias
254
269
const req = this ;
255
270
if ( breadcrumbsEnabled ) {
256
- addRequestBreadcrumb ( 'response' , requestUrl , req , res ) ;
271
+ addRequestBreadcrumb ( 'response' , spanData , req , res ) ;
257
272
}
258
273
if ( requestSpan ) {
259
274
if ( res . statusCode ) {
@@ -268,7 +283,7 @@ function _createWrappedRequestMethodFactory(
268
283
const req = this ;
269
284
270
285
if ( breadcrumbsEnabled ) {
271
- addRequestBreadcrumb ( 'error' , requestUrl , req ) ;
286
+ addRequestBreadcrumb ( 'error' , spanData , req ) ;
272
287
}
273
288
if ( requestSpan ) {
274
289
requestSpan . setHttpStatus ( 500 ) ;
@@ -283,7 +298,12 @@ function _createWrappedRequestMethodFactory(
283
298
/**
284
299
* Captures Breadcrumb based on provided request/response pair
285
300
*/
286
- function addRequestBreadcrumb ( event : string , url : string , req : http . ClientRequest , res ?: http . IncomingMessage ) : void {
301
+ function addRequestBreadcrumb (
302
+ event : string ,
303
+ spanData : Record < string , string > ,
304
+ req : http . ClientRequest ,
305
+ res ?: http . IncomingMessage ,
306
+ ) : void {
287
307
if ( ! getCurrentHub ( ) . getIntegration ( Http ) ) {
288
308
return ;
289
309
}
@@ -294,7 +314,7 @@ function addRequestBreadcrumb(event: string, url: string, req: http.ClientReques
294
314
data : {
295
315
method : req . method ,
296
316
status_code : res && res . statusCode ,
297
- url ,
317
+ ... spanData ,
298
318
} ,
299
319
type : 'http' ,
300
320
} ,
0 commit comments