@@ -58,7 +58,9 @@ class HttpPlugin implements SwPlugin {
5858 host : ( url . host || url . hostname || 'unknown' ) + ':' + ( url . port || 80 ) ,
5959 pathname : url . path || '/' ,
6060 } ;
61- const operation = pathname . replace ( / \? .* $ / g, '' ) ;
61+ const httpMethod = arguments [ url instanceof URL || typeof url === 'string' ? 1 : 0 ] ?. method || 'GET' ;
62+ const httpURL = host + pathname ;
63+ const operation = pathname . replace ( / \? .* $ / g, '' ) ;
6264
6365 let stopped = 0 ; // compensating if request aborted right after creation 'close' is not emitted
6466 const stopIfNotStopped = ( ) => ! stopped ++ ? span . stop ( ) : null ; // make sure we stop only once
@@ -72,10 +74,12 @@ class HttpPlugin implements SwPlugin {
7274 if ( ! span . peer ) {
7375 span . peer = host ;
7476 }
75- const httpURL = host + pathname ;
76- if ( ! span . hasTag ( httpURL ) ) {
77+ if ( ! span . hasTag ( Tag . httpURLKey ) ) { // only set if a higher level plugin with more info did not already set
7778 span . tag ( Tag . httpURL ( httpURL ) ) ;
7879 }
80+ if ( ! span . hasTag ( Tag . httpMethodKey ) ) {
81+ span . tag ( Tag . httpMethod ( httpMethod ) ) ;
82+ }
7983
8084 const req : ClientRequest = _request . apply ( this , arguments ) ;
8185
@@ -154,6 +158,7 @@ class HttpPlugin implements SwPlugin {
154158 ? `[${ req . connection . remoteAddress } ]:${ req . connection . remotePort } `
155159 : `${ req . connection . remoteAddress } :${ req . connection . remotePort } ` ;
156160 span . tag ( Tag . httpURL ( ( req . headers . host || '' ) + req . url ) ) ;
161+ span . tag ( Tag . httpMethod ( req . method ) ) ;
157162
158163 let ret = handler . call ( this , req , res , ...reqArgs ) ;
159164 const type = ret ?. constructor ;
0 commit comments