@@ -242,6 +242,25 @@ describe('HttpInstrumentation', () => {
242242 serverPort
243243 ) ;
244244 } ) ;
245+
246+ it ( 'should remove auth from the `http.url` attribute (client side and server side)' , async ( ) => {
247+ await httpRequest . get (
248+ `${ protocol } ://user:pass@${ hostname } :${ serverPort } ${ pathname } `
249+ ) ;
250+ const spans = memoryExporter . getFinishedSpans ( ) ;
251+ const [ incomingSpan , outgoingSpan ] = spans ;
252+ assert . strictEqual ( spans . length , 2 ) ;
253+ assert . strictEqual ( incomingSpan . kind , SpanKind . SERVER ) ;
254+ assert . strictEqual ( outgoingSpan . kind , SpanKind . CLIENT ) ;
255+ assert . strictEqual (
256+ incomingSpan . attributes [ SEMATTRS_HTTP_URL ] ,
257+ `${ protocol } ://${ hostname } :${ serverPort } ${ pathname } `
258+ ) ;
259+ assert . strictEqual (
260+ outgoingSpan . attributes [ SEMATTRS_HTTP_URL ] ,
261+ `${ protocol } ://${ hostname } :${ serverPort } ${ pathname } `
262+ ) ;
263+ } ) ;
245264 } ) ;
246265
247266 describe ( 'partially disable instrumentation' , ( ) => {
@@ -1143,6 +1162,20 @@ describe('HttpInstrumentation', () => {
11431162 } ) ;
11441163 } ) ;
11451164
1165+ it ( 'should remove auth from the `url.full` attribute (client side and server side)' , async ( ) => {
1166+ await httpRequest . get (
1167+ `${ protocol } ://user:pass@${ hostname } :${ serverPort } ${ pathname } `
1168+ ) ;
1169+ const spans = memoryExporter . getFinishedSpans ( ) ;
1170+ const [ _ , outgoingSpan ] = spans ;
1171+ assert . strictEqual ( spans . length , 2 ) ;
1172+ assert . strictEqual ( outgoingSpan . kind , SpanKind . CLIENT ) ;
1173+ assert . strictEqual (
1174+ outgoingSpan . attributes [ ATTR_URL_FULL ] ,
1175+ `${ protocol } ://${ hostname } :${ serverPort } ${ pathname } `
1176+ ) ;
1177+ } ) ;
1178+
11461179 it ( 'should generate semconv 1.27 server spans with route when RPC metadata is available' , async ( ) => {
11471180 const response = await httpRequest . get (
11481181 `${ protocol } ://${ hostname } :${ serverPort } ${ pathname } /setroute`
0 commit comments