@@ -12,7 +12,7 @@ var consts = require('../consts')
1212var ReservoirSampler = require ( './reservoir_sampler' )
1313
1414var REQUEST_ID = 'request-id'
15- var SPAN_ID = 'span -id'
15+ var PARENT_COMM_ID = 'parent-comm -id'
1616var MUST_COLLECT_LIMIT = 100
1717
1818function Agent ( options ) {
@@ -90,18 +90,18 @@ Agent.prototype.getConfig = function () {
9090
9191Agent . prototype . serverReceive = function ( data ) {
9292 this . totalRequestCount ++
93- var spanId = data . spanId
94- var span = this . openSpan ( data )
95- var parentId
93+ var parentCommId = data . parentCommId
94+ var span = this . openSpan ( data . requestId )
95+ var parentServiceId
9696
97- if ( ! isNaN ( data . parentId ) ) {
98- parentId = parseInt ( data . parentId , 10 )
97+ if ( ! isNaN ( data . parentServiceId ) ) {
98+ parentServiceId = parseInt ( data . parentServiceId , 10 )
9999 }
100100
101101 var transportDelay = data . time - data . originTime
102102
103103 this . incomingEdgeMetrics . report ( {
104- serviceKey : data . parentId ,
104+ serviceKey : data . parentServiceId ,
105105 protocol : data . protocol ,
106106 transportDelay : transportDelay
107107 } )
@@ -110,29 +110,29 @@ Agent.prototype.serverReceive = function (data) {
110110 time : data . time || microtime . now ( ) ,
111111 type : Agent . SERVER_RECV ,
112112 data : {
113- rpcId : spanId ,
113+ rpcId : parentCommId ,
114114 endpoint : data . url ,
115115 method : data . method ,
116- parent : parentId ,
116+ parent : parentServiceId ,
117117 originTime : data . originTime
118118 }
119119 } )
120120}
121121
122122Agent . prototype . serverSend = function ( data ) {
123- var spanId = data . spanId
124- var span = this . findSpan ( data . id )
123+ var parentCommId = data . parentCommId
124+ var span = this . findSpan ( data . requestId )
125125
126126 if ( ! span ) {
127- debug ( 'span was not found for serverSend - it shouldn\'t happen' , data . id , data . spanId )
127+ debug ( 'span was not found for serverSend - it shouldn\'t happen' , data . requestId , data . parentCommId )
128128 return
129129 }
130130
131131 span . events . push ( {
132132 time : data . time || microtime . now ( ) ,
133133 type : Agent . SERVER_SEND ,
134134 data : {
135- rpcId : spanId ,
135+ rpcId : parentCommId ,
136136 statusCode : data . statusCode
137137 }
138138 } )
@@ -143,11 +143,11 @@ Agent.prototype.serverSend = function (data) {
143143 this . reservoirSampler . addReturnsSuccess ( span )
144144 }
145145
146- delete this . partials [ data . id ]
146+ delete this . partials [ data . requestId ]
147147}
148148
149149Agent . prototype . clientSend = function ( data ) {
150- var span = this . findSpan ( data . id )
150+ var span = this . findSpan ( data . requestId )
151151
152152 if ( ! span ) {
153153 return
@@ -165,7 +165,7 @@ Agent.prototype.clientSend = function (data) {
165165 assign ( event , {
166166 type : Agent . ERROR ,
167167 data : {
168- rpcId : data . spanId ,
168+ rpcId : data . childCommId ,
169169 type : data . err . type ,
170170 message : data . err . message ,
171171 raw : data . err . raw
@@ -175,7 +175,7 @@ Agent.prototype.clientSend = function (data) {
175175 assign ( event , {
176176 type : Agent . CLIENT_SEND ,
177177 data : {
178- rpcId : data . spanId ,
178+ rpcId : data . childCommId ,
179179 host : data . host ,
180180 endpoint : data . url ,
181181 method : data . method
@@ -195,12 +195,12 @@ Agent.prototype.clientSend = function (data) {
195195
196196 // for now worker requests are not supported, clean them up
197197 if ( ! hasServerReceive && hasClientSend ) {
198- delete this . partials [ data . id ]
198+ delete this . partials [ data . requestId ]
199199 }
200200}
201201
202202Agent . prototype . clientReceive = function ( data ) {
203- var span = this . findSpan ( data . id )
203+ var span = this . findSpan ( data . requestId )
204204
205205 // report external edges only if service is not instrumented by Trace
206206 if ( typeof data . targetServiceKey === 'undefined' ) {
@@ -224,15 +224,15 @@ Agent.prototype.clientReceive = function (data) {
224224 time : data . time ,
225225 type : Agent . CLIENT_RECV ,
226226 data : {
227- rpcId : data . spanId ,
227+ rpcId : data . childCommId ,
228228 statusCode : data . statusCode
229229 }
230230 } )
231231}
232232
233233Agent . prototype . onCrash = function ( data ) {
234- var span = this . findSpan ( this . getTransactionId ( ) )
235- var spanId = this . getSpanId ( )
234+ var span = this . findSpan ( this . getRequestId ( ) )
235+ var parentCommId = this . getParentCommId ( )
236236
237237 if ( ! span ) {
238238 return
@@ -244,7 +244,7 @@ Agent.prototype.onCrash = function (data) {
244244 time : microtime . now ( ) ,
245245 type : Agent . ERROR ,
246246 data : {
247- rpcId : spanId ,
247+ rpcId : parentCommId ,
248248 type : 'system-error' ,
249249 message : data . stackTrace . message ,
250250 raw : {
@@ -261,9 +261,9 @@ Agent.prototype.onCrash = function (data) {
261261}
262262
263263Agent . prototype . report = function ( name , data , error ) {
264- var traceId = this . getTransactionId ( )
265- var spanId = this . getSpanId ( )
266- var span = this . findSpan ( traceId )
264+ var requestId = this . getRequestId ( )
265+ var parentCommId = this . getParentCommId ( )
266+ var span = this . findSpan ( requestId )
267267
268268 if ( ! span ) {
269269 return
@@ -276,7 +276,7 @@ Agent.prototype.report = function (name, data, error) {
276276 assign ( event , {
277277 type : Agent . ERROR ,
278278 data : {
279- rpcId : spanId ,
279+ rpcId : parentCommId ,
280280 name : name ,
281281 type : 'user-sent-error' ,
282282 message : data . message ,
@@ -287,7 +287,7 @@ Agent.prototype.report = function (name, data, error) {
287287 assign ( event , {
288288 type : Agent . USER_SENT ,
289289 data : {
290- rpcId : spanId ,
290+ rpcId : parentCommId ,
291291 name : name ,
292292 raw : data
293293 }
@@ -301,7 +301,7 @@ Agent.prototype.report = function (name, data, error) {
301301
302302 if ( ! isFound ) {
303303 span . events . push ( event )
304- this . partials [ traceId ] = span
304+ this . partials [ requestId ] = span
305305 } else {
306306 debug ( 'Already has a user-sent event with the name "%s"' , name )
307307 }
@@ -311,15 +311,15 @@ Agent.prototype.reportError = function (errorName, errorData) {
311311 this . report ( errorName , errorData , true )
312312}
313313
314- Agent . prototype . findSpan = function ( transactionId ) {
314+ Agent . prototype . findSpan = function ( requestId ) {
315315 var span
316316 // check if we have a partial with the id
317- if ( ! transactionId || ! this . partials [ transactionId ] || ! this . partials [ transactionId ] . events ) {
318- debug ( 'missing transaction' , transactionId )
317+ if ( ! requestId || ! this . partials [ requestId ] || ! this . partials [ requestId ] . events ) {
318+ debug ( 'missing transaction' , requestId )
319319 return
320320 }
321321
322- span = this . partials [ transactionId ]
322+ span = this . partials [ requestId ]
323323 // check if we had an SR before, if not, discard the span
324324 var hasServerReceive = span . events . some ( function ( event ) {
325325 return event . type === Agent . SERVER_RECV
@@ -333,9 +333,7 @@ Agent.prototype.findSpan = function (transactionId) {
333333 return span
334334}
335335
336- Agent . prototype . openSpan = function ( data ) {
337- var requestId = data . id
338-
336+ Agent . prototype . openSpan = function ( requestId ) {
339337 if ( ! requestId ) {
340338 return
341339 }
@@ -350,23 +348,23 @@ Agent.prototype.openSpan = function (data) {
350348 return this . partials [ requestId ]
351349}
352350
353- Agent . prototype . setTransactionId = function ( value ) {
351+ Agent . prototype . setRequestId = function ( value ) {
354352 return this . cls . set ( REQUEST_ID , value )
355353}
356354
357- Agent . prototype . getTransactionId = function ( ) {
355+ Agent . prototype . getRequestId = function ( ) {
358356 return this . cls . get ( REQUEST_ID )
359357}
360358
361- Agent . prototype . setSpanId = function ( value ) {
362- return this . cls . set ( SPAN_ID , value )
359+ Agent . prototype . setParentCommId = function ( value ) {
360+ return this . cls . set ( PARENT_COMM_ID , value )
363361}
364362
365- Agent . prototype . getSpanId = function ( ) {
366- return this . cls . get ( SPAN_ID )
363+ Agent . prototype . getParentCommId = function ( ) {
364+ return this . cls . get ( PARENT_COMM_ID )
367365}
368366
369- Agent . prototype . clearTransaction = function ( requestId ) {
367+ Agent . prototype . clearRequest = function ( requestId ) {
370368 delete this . partials [ requestId ]
371369}
372370
@@ -378,7 +376,11 @@ Agent.prototype.bindEmitter = function (emitter) {
378376 return this . cls . bindEmitter ( emitter )
379377}
380378
381- Agent . prototype . generateSpanId = function ( ) {
379+ Agent . prototype . generateCommId = function ( ) {
380+ return this . generateId ( )
381+ }
382+
383+ Agent . prototype . generateRequestId = function ( ) {
382384 return this . generateId ( )
383385}
384386
0 commit comments