@@ -3,6 +3,7 @@ var url = require('url')
3
3
var microtime = require ( 'microtime' )
4
4
5
5
var util = require ( './util' )
6
+ var consts = require ( '../../../consts' )
6
7
7
8
function wrapRequest ( originalHttpRequest , agent , mustCollectStore ) {
8
9
var whiteListHosts = agent . getConfig ( ) . whiteListHosts
@@ -41,7 +42,7 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
41
42
42
43
if ( mustCollectStore [ requestId ] ) {
43
44
debug ( 'trace event (cs); reqId: %s, spanId: %s must collect' , requestId , spanId )
44
- requestParams . headers [ 'x-must-collect' ] = '1'
45
+ requestParams . headers [ 'x-must-collect' ] = consts . MUST_COLLECT . ERROR
45
46
}
46
47
47
48
if ( typeof agent . getServiceKey ( ) !== 'undefined' ) {
@@ -59,7 +60,7 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
59
60
url : util . formatDataUrl ( requestParams . path ) ,
60
61
time : clientSendTime ,
61
62
method : requestParams . method ,
62
- mustCollect : ! ! mustCollectStore [ requestId ]
63
+ mustCollect : mustCollectStore [ requestId ]
63
64
}
64
65
65
66
// Collect request start
@@ -79,7 +80,7 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
79
80
spanId : spanId ,
80
81
host : requestParams . host ,
81
82
url : util . formatDataUrl ( requestParams . path ) ,
82
- mustCollect : true ,
83
+ mustCollect : consts . MUST_COLLECT . ERROR ,
83
84
err : {
84
85
type : 'network-error' ,
85
86
message : err . message ,
@@ -97,8 +98,8 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
97
98
98
99
// returns with response
99
100
returned . on ( 'response' , function ( incomingMessage ) {
100
- mustCollectStore [ requestId ] = ! ! incomingMessage . headers [ 'x-must-collect' ] ||
101
- ! ! mustCollectStore [ requestId ]
101
+ mustCollectStore [ requestId ] = incomingMessage . headers [ 'x-must-collect' ] ||
102
+ mustCollectStore [ requestId ]
102
103
103
104
if ( mustCollectStore [ requestId ] ) {
104
105
debug ( 'trace event (cr) on response; reqId: %s, spanId: %s must collect' , requestId , spanId )
0 commit comments