@@ -60,26 +60,29 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
6060 return date . toISOString ( ) ;
6161 }
6262
63+ let serverHostPort = "mythical-server:4000"
64+ // check env var for override
65+ if ( process . env . MYTHICAL_SERVER_HOST_PORT ) {
66+ serverHostPort = process . env . MYTHICAL_SERVER_HOST_PORT
67+ }
68+
6369 // Create a new span, link to previous request to show how linking between traces works.
6470 const requestSpan = tracer . startSpan ( 'requester' , {
6571 kind : api . SpanKind . CLIENT ,
6672 links : ( previousReqSpanContext ) ? [ { context : previousReqSpanContext } ] : undefined ,
6773 } ) ;
74+
6875 requestSpan . setAttribute ( spanTag , endpoint ) ;
69- requestSpan . setAttribute ( `http.target` , '/' + endpoint ) ;
70- requestSpan . setAttribute ( `http.method` , type ) ;
76+ requestSpan . setAttribute ( `url.full` , `http://${ serverHostPort } /${ endpoint } ` ) ;
77+ requestSpan . setAttribute ( `url.path` , '/' + endpoint ) ;
78+ requestSpan . setAttribute ( `http.request.method` , type ) ;
7179 requestSpan . setAttribute ( 'service.version' , ( Math . floor ( Math . random ( ) * 100 ) ) < 50 ? '1.9.2' : '2.0.0' ) ;
7280 previousReqSpanContext = requestSpan . spanContext ( ) ;
7381 const { traceId } = requestSpan . spanContext ( ) ;
7482
7583 // Increment the danger level on the gauge
7684 dangerGauge . inc ( dangerLevel ) ;
7785
78- let serverHostPort = "mythical-server:4000"
79- // check env var for override
80- if ( process . env . MYTHICAL_SERVER_HOST_PORT ) {
81- serverHostPort = process . env . MYTHICAL_SERVER_HOST_PORT
82- }
8386
8487 // Create a new context for this request
8588 api . context . with ( api . trace . setSpan ( api . context . active ( ) , requestSpan ) , async ( ) => {
@@ -98,7 +101,7 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
98101 job : `${ servicePrefix } -requester` ,
99102 endpointLabel : spanTag ,
100103 endpoint,
101- message : `traceID=${ traceId } http.method=GET endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
104+ message : `traceID=${ traceId } http.request. method=GET endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
102105 } ) ;
103106 names = result . data ;
104107
@@ -117,7 +120,7 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
117120 job : `${ servicePrefix } -requester` ,
118121 endpointLabel : spanTag ,
119122 endpoint,
120- message : `traceID=${ traceId } http.method=DELETE endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
123+ message : `traceID=${ traceId } http.request. method=DELETE endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
121124 } ) ;
122125 }
123126 }
@@ -128,7 +131,7 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
128131 job : `${ servicePrefix } -requester` ,
129132 endpointLabel : spanTag ,
130133 endpoint,
131- message : `traceID=${ traceId } http.method=DELETE endpoint=${ endpoint } ` +
134+ message : `traceID=${ traceId } http.request. method=DELETE endpoint=${ endpoint } ` +
132135 `name=${ ( names ) ? names [ 0 ] . name : 'unknown' } status=FAILURE loggedtime=${ timeshift ( ) } ` ,
133136 } ) ;
134137 error = true ;
@@ -146,7 +149,7 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
146149 job : `${ servicePrefix } -requester` ,
147150 endpointLabel : spanTag ,
148151 endpoint,
149- message : `traceID=${ traceId } http.method=POST endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
152+ message : `traceID=${ traceId } http.request. method=POST endpoint=${ endpoint } loggedtime=${ timeshift ( ) } status=SUCCESS` ,
150153 } ) ;
151154 } catch ( err ) {
152155 // The error condition is a little different here to using request. Axios throws a more generic error
@@ -158,20 +161,19 @@ const makeRequest = async (tracingObj, sendMessage, logEntry) => {
158161 job : `${ servicePrefix } -requester` ,
159162 endpointLabel : spanTag ,
160163 endpoint,
161- message : `traceID=${ traceId } http.method=POST endpoint=${ endpoint } name=${ randomName } ` +
164+ message : `traceID=${ traceId } http.request. method=POST endpoint=${ endpoint } name=${ randomName } ` +
162165 ` loggedtime=${ timeshift ( ) } status=FAILURE` ,
163166 } ) ;
164167 error = true ;
165168 }
166-
167169 }
168170 logEntry ( {
169171 level : 'info' ,
170172 namespace : process . env . NAMESPACE ,
171173 job : `${ servicePrefix } -requester` ,
172174 endpointLabel : spanTag ,
173175 endpoint,
174- message : `traceID=${ traceId } http.method=${ type } endpoint=${ endpoint } duration=${ Date . now ( ) - start } ms loggedtime=${ timeshift ( ) } ` ,
176+ message : `traceID=${ traceId } http.request. method=${ type } endpoint=${ endpoint } duration=${ Date . now ( ) - start } ms loggedtime=${ timeshift ( ) } ` ,
175177 } ) ;
176178
177179 // Set the status code as OK and end the span
0 commit comments