This repository was archived by the owner on Oct 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
packages/opencensus-instrumentation-http/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,9 +198,11 @@ export class HttpPlugin extends BasePlugin {
198198 }
199199
200200 // Makes sure the url is an url object
201+ let pathname = '' ;
201202 if ( typeof ( options ) === 'string' ) {
202203 options = url . parse ( options ) ;
203204 arguments [ 0 ] = options ;
205+ pathname = options . pathname ;
204206 } else {
205207 // Do not trace ourselves
206208 if ( options . headers &&
@@ -209,6 +211,11 @@ export class HttpPlugin extends BasePlugin {
209211 'header with "x-opencensus-outgoing-request" - do not trace' ) ;
210212 return original . apply ( this , arguments ) ;
211213 }
214+
215+ try {
216+ pathname = options . pathname || url . parse ( options . path ) . pathname ;
217+ } catch ( e ) {
218+ }
212219 }
213220
214221 const request = original . apply ( this , arguments ) ;
@@ -217,8 +224,7 @@ export class HttpPlugin extends BasePlugin {
217224
218225 plugin . logger . debug ( '%s plugin outgoingRequest' , plugin . moduleName ) ;
219226 const traceOptions = {
220- name :
221- `${ request . method ? request . method : 'GET' } ${ options . pathname } ` ,
227+ name : `${ request . method ? request . method : 'GET' } ${ pathname } ` ,
222228 kind : 'CLIENT' ,
223229 } ;
224230
You can’t perform that action at this time.
0 commit comments