whatap 0.4.81 → 0.4.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/conf/config-default.js +21 -14
- package/lib/logger.js +5 -1
- package/lib/observers/http-observer.js +144 -82
- package/lib/observers/maria-observer.js +17 -1
- package/lib/observers/mongo-observer.js +71 -22
- package/lib/observers/mssql-observer.js +21 -4
- package/lib/observers/mysql-observer.js +17 -1
- package/lib/observers/pgsql-observer.js +27 -11
- package/lib/trace/trace-context-manager.js +12 -8
- package/logs/whatap-20231109.log +54 -0
- package/logs/whatap-20231124.log +18 -0
- package/logs/whatap-20231211.log +110 -0
- package/package.json +2 -2
- package/logs/whatap-20231101.log +0 -293
|
@@ -42,7 +42,7 @@ var ConfigDefault = {
|
|
|
42
42
|
"trace_activeserivce_yellow_time": 3000,
|
|
43
43
|
"trace_activeservice_red_time": 8000,
|
|
44
44
|
"trace_activeservice_hang_time": 6000,
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
"trace_httpc_normalize_urls": "",
|
|
47
47
|
"log_ignore_set": null,
|
|
48
48
|
"whatap.server.host": str('whatap_server_host',"127.0.0.1,127.0.0.1"),
|
|
@@ -71,7 +71,7 @@ var ConfigDefault = {
|
|
|
71
71
|
"hook_method_ignore_prefixes": "get,set",
|
|
72
72
|
"hook_method_ignore_classes": "",
|
|
73
73
|
"profile_method_enabled": true,
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
"hook_service_patterns": "",
|
|
76
76
|
"hook_httpc_patterns": "",
|
|
77
77
|
"hook_httpc_info_patterns": "",
|
|
@@ -92,25 +92,30 @@ var ConfigDefault = {
|
|
|
92
92
|
"user_header_ticket": str('user_header_ticket',''),
|
|
93
93
|
"user_header_ticket_enabled": bool('user_header_ticket_enabled',false),
|
|
94
94
|
"trace_user_cookie_limit": 2048,
|
|
95
|
+
"trace_sql_error_stack": bool('trace_sql_error_stack', false),
|
|
96
|
+
"trace_sql_error_depth": num('trace_sql_error_depth', 50),
|
|
97
|
+
"transaction_status_error_enable": bool("transaction_status_error_enable", true),
|
|
95
98
|
|
|
96
|
-
"profile_error_sql_time_max": 30000,
|
|
99
|
+
"profile_error_sql_time_max": num("profile_error_sql_time_max", 30000),
|
|
100
|
+
"profile_error_step_enabled": bool('profile_error_step_enabled', true),
|
|
97
101
|
"hook_direct_patch_classes": "",
|
|
98
|
-
|
|
102
|
+
|
|
99
103
|
"log_rotation_enabled": bool('log_rotation_enabled',true),
|
|
104
|
+
"log_oname_enabled": bool('log_oname_enabled',false),
|
|
100
105
|
"log_keep_days": num('log_keep_days' , 7),
|
|
101
106
|
"log_print_enabled": bool('log_print_enabled',true),
|
|
102
107
|
"log_file_enabled" : bool('log_file_enabled',true),
|
|
103
108
|
"thread_dump_enabled": bool('thread_dump_enabled',false),
|
|
104
109
|
"debug_cpu_enabled": bool('debug_cpu_enabled',false),
|
|
105
|
-
|
|
110
|
+
|
|
106
111
|
"cipher_net_enabled": true,
|
|
107
112
|
"cipher_level": 2,
|
|
108
113
|
'cypher_level': 128,
|
|
109
114
|
"boot_redefine_size": 100,
|
|
110
|
-
|
|
115
|
+
|
|
111
116
|
"counter_interval": 5000,
|
|
112
117
|
"CONFIG_INITED": true,
|
|
113
|
-
|
|
118
|
+
|
|
114
119
|
// "_profile_position_httpc_hash": 0,
|
|
115
120
|
// "profile_position_httpc": "",
|
|
116
121
|
// "_profile_position_sql_hash": 0,
|
|
@@ -126,7 +131,9 @@ var ConfigDefault = {
|
|
|
126
131
|
"trace_active_transaction_hang_time" : num('trace_active_transaction_hang_time', 30000),
|
|
127
132
|
"realtime_user_thinktime_max" : 300000,
|
|
128
133
|
"trace_service_port_enabled" : bool('trace_service_port_enabled',false),
|
|
129
|
-
|
|
134
|
+
"ignore_http_method": str('ignore_http_method', 'PATCH,OPTIONS,HEAD,TRACE'),
|
|
135
|
+
"status_ignore": str('status_ignore', ''),
|
|
136
|
+
"status_ignore_set": str('status_ignore_set', ''),
|
|
130
137
|
"trace_sql_normalize_enabled" : true,
|
|
131
138
|
|
|
132
139
|
//2017.05.02 AUTO ONAME
|
|
@@ -173,25 +180,25 @@ var ConfigDefault = {
|
|
|
173
180
|
"whatap_micro_enabled": bool('whatap_micro_enabled',false),
|
|
174
181
|
"master_agent_host": str('master_agent_host', 'whatap-master-agent.whatap-monitoring.svc.cluster.local'),
|
|
175
182
|
"master_agent_port": num('master_agent_port', 6600),
|
|
176
|
-
"enabled_master_agent_call": bool('enabled_master_agent_call' , false),
|
|
183
|
+
"enabled_master_agent_call": bool('enabled_master_agent_call' , false),
|
|
177
184
|
|
|
178
185
|
"simula_agent_count": num('simula_agent_count', 0),
|
|
179
186
|
"correction_factor_cpu": num('correction_factor_cpu', 1),
|
|
180
187
|
"aws_ecs_enabled": bool('aws_ecs_enabled', true),
|
|
181
188
|
"aws_ecs_stat_interval": num('aws_ecs_stat_interval', 3000),
|
|
182
|
-
|
|
189
|
+
|
|
183
190
|
// stat_service1_enabled
|
|
184
191
|
"stat_service1_enabled": bool('stat_service1_enabled', true),
|
|
185
192
|
"stat_mtrace_max_count": num('stat_mtrace_max_count', 7000),
|
|
186
193
|
|
|
187
194
|
"_trace_mtrace_poid_key": str("mtrace_poid_key", "x-wtap-po"),
|
|
188
|
-
|
|
195
|
+
"_trace_mtrace_caller_key": str("mtrace_caller_key","x-wtap-mst"),
|
|
189
196
|
"_trace_mtrace_spec_key1": str("mtrace_spec_key", "x-wtap-sp1"),
|
|
190
|
-
|
|
197
|
+
|
|
191
198
|
// add apdex 2020.11.13
|
|
192
199
|
"apdex_time_t": num('apdex_time_t', 1200),
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
"apdex_time_4t": num('apdex_time_4t', 1200 * 4),
|
|
201
|
+
"debug_apdex_enabled": bool('debug_apdex_enabled', false),
|
|
195
202
|
"mtid_mtrace_enabled": bool('mtid_mtrace_enabled' , false),
|
|
196
203
|
|
|
197
204
|
// debug add
|
package/lib/logger.js
CHANGED
|
@@ -149,7 +149,11 @@
|
|
|
149
149
|
},
|
|
150
150
|
build : function (id, message) {
|
|
151
151
|
var str = DateUtil.datetime(Date.now());
|
|
152
|
-
str += '
|
|
152
|
+
// str += ' ';
|
|
153
|
+
// if(conf.getProperty('log_oname_enabled') && this.ONAME) {
|
|
154
|
+
// str += '[' + this.ONAME + ']'
|
|
155
|
+
// }
|
|
156
|
+
str += '[';
|
|
153
157
|
str += id;
|
|
154
158
|
str += '] <' + PID + '> ';
|
|
155
159
|
str += message;
|
|
@@ -39,10 +39,15 @@ var TraceContextManager = require('../trace/trace-context-manager'),
|
|
|
39
39
|
|
|
40
40
|
var _exts=new Set([".css",".js",".png", ".htm", ".html", ".gif", ".jpg", ".css", ".txt", ".ico"]);
|
|
41
41
|
|
|
42
|
-
var configIpHeaderKey = conf.trace_http_client_ip_header_key;
|
|
43
|
-
var configUserAgentKey =
|
|
44
|
-
var configRefererKey =
|
|
45
|
-
var trace_origin_url = conf.trace_origin_url;
|
|
42
|
+
var configIpHeaderKey = conf.getProperty('trace_http_client_ip_header_key', 'x-forwarded-for');
|
|
43
|
+
var configUserAgentKey = conf.getProperty('trace_user_agent_header_key', '');
|
|
44
|
+
var configRefererKey = conf.getProperty('trace_referer_header_key', '');
|
|
45
|
+
var trace_origin_url = conf.getProperty('trace_origin_url', false);
|
|
46
|
+
var ignore_http_method = conf.getProperty('ignore_http_method', 'PATCH,OPTIONS,HEAD,TRACE');
|
|
47
|
+
var transaction_status_error_enable = conf.getProperty('transaction_status_error_enable', true);
|
|
48
|
+
var status_ignore = conf.getProperty('status_ignore', '');
|
|
49
|
+
var status_ignore_set = conf.getProperty('status_ignore_set', '');
|
|
50
|
+
var profile_error_step_enabled = conf.getProperty('profile_error_step_enabled', '');
|
|
46
51
|
conf.on('trace_http_client_ip_header_key', function(newProperty) {
|
|
47
52
|
configIpHeaderKey = newProperty;
|
|
48
53
|
});
|
|
@@ -64,7 +69,21 @@ conf.on('trace_referer_header_key', function (newProps) {
|
|
|
64
69
|
conf.on('trace_origin_url', function (newProps) {
|
|
65
70
|
trace_origin_url = newProps;
|
|
66
71
|
})
|
|
67
|
-
|
|
72
|
+
conf.on('ignore_http_method', function (newProps) {
|
|
73
|
+
ignore_http_method = newProps;
|
|
74
|
+
})
|
|
75
|
+
conf.on('transaction_status_error_enable', function (newProps) {
|
|
76
|
+
transaction_status_error_enable = newProps;
|
|
77
|
+
})
|
|
78
|
+
conf.on('status_ignore', function (newProps) {
|
|
79
|
+
status_ignore = !newProps ? "" : String(newProps);
|
|
80
|
+
})
|
|
81
|
+
conf.on('status_ignore_set', function (newProps) {
|
|
82
|
+
status_ignore_set = newProps;
|
|
83
|
+
})
|
|
84
|
+
conf.on('profile_error_step_enabled', function (newProps) {
|
|
85
|
+
profile_error_step_enabled = newProps;
|
|
86
|
+
})
|
|
68
87
|
var staticConents = function (newProps) {
|
|
69
88
|
var x=new Set();
|
|
70
89
|
var words = !newProps?[]:newProps.split(',');
|
|
@@ -78,7 +97,7 @@ var staticConents = function (newProps) {
|
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
|
-
|
|
100
|
+
|
|
82
101
|
_exts =x;
|
|
83
102
|
};
|
|
84
103
|
conf.on('web_static_content_extensions', staticConents);
|
|
@@ -95,64 +114,79 @@ HttpObserver.prototype.__createTransactionObserver = function(callback, isHttps,
|
|
|
95
114
|
var aop = this.agent.aop;
|
|
96
115
|
|
|
97
116
|
return function (req, res) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var originUrlHash = HashUtil.hashFromString('Origin url');
|
|
104
|
-
var step = new MessageStep();
|
|
105
|
-
step.hash = originUrlHash;
|
|
106
|
-
step.start_time = ctx.getElapsedTime();
|
|
107
|
-
// step.desc = req.url;
|
|
108
|
-
|
|
109
|
-
DataTextAgent.MESSAGE.add(originUrlHash, 'Origin url');
|
|
110
|
-
ctx.profile.add(step);
|
|
111
|
-
}
|
|
117
|
+
TraceContextManager._asyncLocalStorage.run(initCtx(req, res), () => {
|
|
118
|
+
var ctx = TraceContextManager._asyncLocalStorage.getStore();
|
|
119
|
+
if(!ctx) {
|
|
120
|
+
return callback(req, res);
|
|
121
|
+
}
|
|
112
122
|
|
|
113
|
-
|
|
114
|
-
if(
|
|
115
|
-
|
|
123
|
+
PluginLoaderManager.do('httpservicestart', ctx, req, res);
|
|
124
|
+
if(trace_origin_url === true){
|
|
125
|
+
var originUrlHash = HashUtil.hashFromString('Origin url');
|
|
126
|
+
var step = new MessageStep();
|
|
127
|
+
step.hash = originUrlHash;
|
|
128
|
+
step.start_time = ctx.getElapsedTime();
|
|
129
|
+
// step.desc = req.url;
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if(conf.profile_http_querystring_enabled){
|
|
120
|
-
ctx.http_query = JSON.stringify(req.query);
|
|
121
|
-
}
|
|
122
|
-
ctx.http_content_type = (req.headers['content_type'] || '');
|
|
123
|
-
ctx.status = Math.floor(obj.statusCode / 100);
|
|
124
|
-
|
|
125
|
-
// 에러가 발생했지만 스택수집안했을 경우
|
|
126
|
-
if (ctx.status >= 4 && ctx.error.isZero()) {
|
|
127
|
-
ctx.error = StatError.addError(obj.statusCode, obj.statusMessage,
|
|
128
|
-
ctx.service_hash);
|
|
129
|
-
ctx.statusCode = obj.statusCode;
|
|
130
|
-
ctx.statusMessage = obj.statusMessage;
|
|
131
|
+
DataTextAgent.MESSAGE.add(originUrlHash, 'Origin url');
|
|
132
|
+
ctx.profile.add(step);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
aop.after(res, 'end', function(obj, args) {
|
|
136
|
+
if(ctx == null) { return; }
|
|
137
|
+
PluginLoaderManager.do('httpserviceend', ctx, req, res);
|
|
135
138
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
ctx.isStaticContents = isStatic(req.url);
|
|
140
|
+
ctx.http_method = req.method;
|
|
141
|
+
if(conf.profile_http_querystring_enabled){
|
|
142
|
+
ctx.http_query = JSON.stringify(req.query);
|
|
143
|
+
}
|
|
144
|
+
ctx.http_content_type = (req.headers['content_type'] || '');
|
|
145
|
+
ctx.status = Math.floor(obj.statusCode / 100);
|
|
146
|
+
|
|
147
|
+
// 에러가 발생했지만 스택수집안했을 경우
|
|
148
|
+
if (transaction_status_error_enable && ctx.status >= 4 && ctx.error.isZero()) {
|
|
149
|
+
ctx.error = StatError.addError(obj.statusCode, obj.statusMessage,
|
|
150
|
+
ctx.service_hash);
|
|
151
|
+
ctx.statusCode = obj.statusCode;
|
|
152
|
+
ctx.statusMessage = obj.statusMessage;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var requestPath = '';
|
|
156
|
+
if(req.route && req.route.path)
|
|
157
|
+
requestPath = req.route.path;
|
|
158
|
+
var is_ignore = shouldIgnoreError(res.statusCode, requestPath, status_ignore, status_ignore_set);
|
|
159
|
+
if(!is_ignore)
|
|
160
|
+
self.__endTransaction(null, ctx, req, res);
|
|
161
|
+
else{
|
|
162
|
+
TraceContextManager.end(ctx._id);
|
|
163
|
+
ctx = null;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
return callback.apply(this, arguments);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
Logger.printError("WHATAP-606", 'Hooking request failed..', e, false);
|
|
171
|
+
self.__endTransaction(e, ctx, req, res);
|
|
172
|
+
throw e;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
143
175
|
};
|
|
176
|
+
|
|
144
177
|
};
|
|
145
178
|
|
|
146
179
|
function isStatic(u){
|
|
147
180
|
var x = u.lastIndexOf('.');
|
|
148
181
|
if(x<=0) return false;
|
|
149
|
-
|
|
182
|
+
|
|
150
183
|
var ext = u.substring(x);
|
|
151
184
|
return _exts.has(ext);
|
|
152
185
|
}
|
|
153
186
|
function initCtx(req, res) {
|
|
154
187
|
/*url이 없으면 추적하지 않는다*/
|
|
155
188
|
if(req.url == null) { return null; }
|
|
189
|
+
if(ignore_http_method && ignore_http_method.toUpperCase().split(',').includes(req.method)) { return null; }
|
|
156
190
|
|
|
157
191
|
var ctx = TraceContextManager.start();
|
|
158
192
|
if(ctx == null) { return null; }
|
|
@@ -230,7 +264,7 @@ function initCtx(req, res) {
|
|
|
230
264
|
MeterUsers.add(ctx.userid);
|
|
231
265
|
break;
|
|
232
266
|
case 2:
|
|
233
|
-
|
|
267
|
+
// MeterUsers.add(ctx.userid);
|
|
234
268
|
break;
|
|
235
269
|
case 3:
|
|
236
270
|
ctx.userid = UserIdUtil.getUserId(req, res, 0);
|
|
@@ -240,9 +274,9 @@ function initCtx(req, res) {
|
|
|
240
274
|
|
|
241
275
|
} catch (e) {
|
|
242
276
|
}
|
|
243
|
-
/************************************/
|
|
277
|
+
/************************************/
|
|
244
278
|
/* Header / param Trace */
|
|
245
|
-
/************************************/
|
|
279
|
+
/************************************/
|
|
246
280
|
var header_enabled = false;
|
|
247
281
|
if(conf.profile_http_header_enabled === true && req.headers) {
|
|
248
282
|
header_enabled = true;
|
|
@@ -251,7 +285,7 @@ function initCtx(req, res) {
|
|
|
251
285
|
header_enabled = false;
|
|
252
286
|
}
|
|
253
287
|
}
|
|
254
|
-
|
|
288
|
+
|
|
255
289
|
if(header_enabled) {
|
|
256
290
|
var step = new MessageStep();
|
|
257
291
|
step.hash = HashUtil.hashFromString("HTTP-HEADERS");
|
|
@@ -260,9 +294,9 @@ function initCtx(req, res) {
|
|
|
260
294
|
DataTextAgent.MESSAGE.add(step.hash, "HTTP-HEADERS");
|
|
261
295
|
ctx.profile.push(step);
|
|
262
296
|
}
|
|
263
|
-
/************************************/
|
|
297
|
+
/************************************/
|
|
264
298
|
/* Multi Server Transaction Trace */
|
|
265
|
-
/************************************/
|
|
299
|
+
/************************************/
|
|
266
300
|
if(conf.mtrace_enabled) {
|
|
267
301
|
var poid=req.headers['x-wtap-po'];
|
|
268
302
|
if (poid != null) {
|
|
@@ -308,7 +342,7 @@ function initCtx(req, res) {
|
|
|
308
342
|
}
|
|
309
343
|
}
|
|
310
344
|
}
|
|
311
|
-
|
|
345
|
+
|
|
312
346
|
return ctx;
|
|
313
347
|
};
|
|
314
348
|
|
|
@@ -338,7 +372,16 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
|
|
|
338
372
|
DataTextAgent.MESSAGE.add(step.hash, "HTTP-PARAMETERS");
|
|
339
373
|
ctx.profile.push(step);
|
|
340
374
|
}
|
|
341
|
-
|
|
375
|
+
|
|
376
|
+
if(profile_error_step_enabled && ctx.statusMessage){
|
|
377
|
+
var step = new MessageStep();
|
|
378
|
+
step.hash = HashUtil.hashFromString("EXCEPTION");
|
|
379
|
+
step.start_time = ctx.getElapsedTime();
|
|
380
|
+
step.desc = ctx.statusMessage;
|
|
381
|
+
DataTextAgent.MESSAGE.add(step.hash, "EXCEPTION");
|
|
382
|
+
ctx.profile.push(step);
|
|
383
|
+
}
|
|
384
|
+
|
|
342
385
|
if(error) {
|
|
343
386
|
TraceContextManager.end(ctx != null ? ctx._id : null);
|
|
344
387
|
ctx = null;
|
|
@@ -389,7 +432,7 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
|
|
|
389
432
|
if (ctx.error.isZero() === false) {
|
|
390
433
|
wtx.error = ctx.error;
|
|
391
434
|
wtx.errorLevel = EventLevel.WARNING;
|
|
392
|
-
}
|
|
435
|
+
}
|
|
393
436
|
wtx.userAgent = ctx.userAgent;
|
|
394
437
|
wtx.referer = ctx.referer;
|
|
395
438
|
|
|
@@ -407,17 +450,17 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
|
|
|
407
450
|
wtx.mcaller_okind = ctx.mcaller_okind;
|
|
408
451
|
wtx.mcaller_oid = ctx.mcaller_oid;
|
|
409
452
|
|
|
410
|
-
MeterService.add(wtx.service, wtx.elapsed,
|
|
453
|
+
MeterService.add(wtx.service, wtx.elapsed,
|
|
411
454
|
wtx.errorLevel, ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
|
|
412
455
|
|
|
413
456
|
profile.oid = SecurityMaster.OID;
|
|
414
457
|
profile.service = wtx;
|
|
415
|
-
if(Boolean(conf.reqlog_enabled) == true) {
|
|
458
|
+
if(Boolean(conf.reqlog_enabled) == true) {
|
|
416
459
|
ctx.endTime = wtx.endTime;
|
|
417
460
|
ctx.elapsed = wtx.elapsed;
|
|
418
461
|
RequestLog.setRecord(ctx);
|
|
419
462
|
}
|
|
420
|
-
//duplicated executed... so end() first
|
|
463
|
+
//duplicated executed... so end() first
|
|
421
464
|
TraceContextManager.end(ctx._id);
|
|
422
465
|
setTimeout(function () {
|
|
423
466
|
DataProfileAgent.sendProfile(ctx, profile, false);
|
|
@@ -438,14 +481,14 @@ function transferPOID(ctx) {
|
|
|
438
481
|
if (transfer_poid)
|
|
439
482
|
return transfer_poid;
|
|
440
483
|
transfer_poid=Hexa32.toString32(SecurityMaster.PCODE)+','
|
|
441
|
-
|
|
484
|
+
+Hexa32.toString32(SecurityMaster.OKIND)+','+Hexa32.toString32(SecurityMaster.OID);
|
|
442
485
|
return transfer_poid;
|
|
443
486
|
}
|
|
444
487
|
|
|
445
488
|
function transferMTID_CALLERTX(ctx) {
|
|
446
489
|
if (ctx.transfer_id)
|
|
447
490
|
return ctx.transfer_id;
|
|
448
|
-
var x = Hexa32.toString32(ctx.mtid) + ',' + (ctx.mdepth + 1) + ',' + Hexa32.toString32(ctx.txid);
|
|
491
|
+
var x = Hexa32.toString32(ctx.mtid) + ',' + (ctx.mdepth + 1) + ',' + Hexa32.toString32(ctx.txid);
|
|
449
492
|
ctx.transfer_id = x;
|
|
450
493
|
return ctx.transfer_id;
|
|
451
494
|
}
|
|
@@ -525,7 +568,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
525
568
|
|
|
526
569
|
aop.before(mod.Server.prototype, ['on', 'addListener'], function (obj, args) {
|
|
527
570
|
if(args[0] !== 'request') {return;}
|
|
528
|
-
|
|
571
|
+
|
|
529
572
|
args[args.length-1] = self.__createTransactionObserver(args[args.length-1],
|
|
530
573
|
moduleName === 'https', obj);
|
|
531
574
|
});
|
|
@@ -545,7 +588,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
545
588
|
if(moduleName === 'http' && args[0].__isHttps) {
|
|
546
589
|
isHttpsRepeat = true;
|
|
547
590
|
}
|
|
548
|
-
|
|
591
|
+
|
|
549
592
|
if(!isHttpsRepeat) {
|
|
550
593
|
try {
|
|
551
594
|
if(args[0].method === 'OPTION') {
|
|
@@ -553,12 +596,12 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
553
596
|
}
|
|
554
597
|
|
|
555
598
|
var dataConsumption = false;
|
|
556
|
-
|
|
599
|
+
|
|
557
600
|
if(args.length > 0) {
|
|
558
601
|
var info = args[0];
|
|
559
|
-
|
|
560
|
-
interTxTraceAutoOn(ctx);
|
|
561
|
-
|
|
602
|
+
|
|
603
|
+
interTxTraceAutoOn(ctx);
|
|
604
|
+
|
|
562
605
|
if(conf.mtrace_enabled){
|
|
563
606
|
if(info.headers){
|
|
564
607
|
info.headers['x-wtap-po']=transferPOID(ctx);
|
|
@@ -570,8 +613,8 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
570
613
|
if(conf.stat_mtrace_enabled){
|
|
571
614
|
info.headers[conf._trace_mtrace_spec_key1]=transferSPEC_URL(ctx);
|
|
572
615
|
}
|
|
573
|
-
if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
|
|
574
|
-
info.headers[conf._trace_mtrace_caller_key]=transferMTID_CALLERTX(ctx);
|
|
616
|
+
if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
|
|
617
|
+
info.headers[conf._trace_mtrace_caller_key]=transferMTID_CALLERTX(ctx);
|
|
575
618
|
}
|
|
576
619
|
|
|
577
620
|
}
|
|
@@ -579,11 +622,11 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
579
622
|
ctx.httpc_host = info.host || info.hostname || '';
|
|
580
623
|
ctx.httpc_port = info.port || -1;
|
|
581
624
|
}
|
|
582
|
-
ctx.footprint('Http Call Start');
|
|
625
|
+
ctx.footprint('Http Call Start');
|
|
583
626
|
|
|
584
627
|
if (ctx.httpc_port < 0) { ctx.httpc_port = 80 };
|
|
585
628
|
|
|
586
|
-
} catch(e) {
|
|
629
|
+
} catch(e) {
|
|
587
630
|
return Logger.printError('WHATAP-852', 'Http Repeat ', e, true);
|
|
588
631
|
}
|
|
589
632
|
|
|
@@ -618,12 +661,12 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
618
661
|
|
|
619
662
|
ret.on('response', function(response){
|
|
620
663
|
var statusCode = response.statusCode;
|
|
621
|
-
if(statusCode >= 400){
|
|
664
|
+
if(transaction_status_error_enable && statusCode >= 400){
|
|
622
665
|
if (step.error.isZero()) {
|
|
623
666
|
step.error = StatError.addError(statusCode, response.statusMessage , ctx.service_hash,
|
|
624
667
|
TextTypes.HTTPC_URL, step.url);
|
|
625
|
-
if (ctx.error.isZero()) {
|
|
626
|
-
ctx.error = step.error;
|
|
668
|
+
if (ctx.error.isZero()) {
|
|
669
|
+
ctx.error = step.error;
|
|
627
670
|
ctx.statusCode = statusCode;
|
|
628
671
|
ctx.statusMessage = response.statusMessage;
|
|
629
672
|
}
|
|
@@ -633,11 +676,11 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
633
676
|
ret.on('error', function(err) {
|
|
634
677
|
if (TraceContextManager.resume(ctx._id) == null) { return; }
|
|
635
678
|
|
|
636
|
-
if (step.error.isZero()) {
|
|
679
|
+
if (transaction_status_error_enable && step.error.isZero()) {
|
|
637
680
|
step.error = StatError.addError(err.code, err.message, ctx.service_hash,
|
|
638
681
|
TextTypes.HTTPC_URL, step.url);
|
|
639
|
-
if (ctx.error.isZero()) {
|
|
640
|
-
ctx.error = step.error;
|
|
682
|
+
if (ctx.error.isZero()) {
|
|
683
|
+
ctx.error = step.error;
|
|
641
684
|
ctx.statusCode = err.code;
|
|
642
685
|
ctx.statusMessage = err.message;
|
|
643
686
|
}
|
|
@@ -666,7 +709,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
666
709
|
}
|
|
667
710
|
}
|
|
668
711
|
});
|
|
669
|
-
|
|
712
|
+
|
|
670
713
|
aop.before(ret, 'end', function (obj, args) {
|
|
671
714
|
ctx.active_httpc_hash = step.url;
|
|
672
715
|
ctx.profile.push(step);
|
|
@@ -680,13 +723,13 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
680
723
|
TraceContextManager.resume(ctx._id);
|
|
681
724
|
endHttpc(ctx, step);
|
|
682
725
|
});
|
|
683
|
-
|
|
726
|
+
|
|
684
727
|
socket.on('timeout', function () {
|
|
685
728
|
if (TraceContextManager.resume(ctx._id) == null) { return; }
|
|
686
729
|
if (step.error.isZero()) {
|
|
687
730
|
var msgObj = { 'class': 'Timeout', 'msg': 'Timeout' };
|
|
688
731
|
step.error = StatError.addError('Timeout','Timeout', ctx.service_hash);
|
|
689
|
-
if (ctx.error.isZero()) {
|
|
732
|
+
if (transaction_status_error_enable && ctx.error.isZero()) {
|
|
690
733
|
ctx.error = step.error;
|
|
691
734
|
ctx.statusCode = 'Timeout';
|
|
692
735
|
ctx.statusMessage = 'Timeout';
|
|
@@ -698,7 +741,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
698
741
|
});
|
|
699
742
|
});
|
|
700
743
|
|
|
701
|
-
function endHttpc(ctx, step) {
|
|
744
|
+
function endHttpc(ctx, step) {
|
|
702
745
|
if(ctx == null || step == null) { return; }
|
|
703
746
|
|
|
704
747
|
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
@@ -708,8 +751,27 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
708
751
|
|
|
709
752
|
MeterHttpC.add(step.host, step.elapsed, step.error.isZero()===false);
|
|
710
753
|
StatHttpc.addHttpcTime(ctx.service_hash, step.url, step.host, step.port, step.elapsed, step.error.isZero()===false);
|
|
711
|
-
ctx.footprint('Http Call Done');
|
|
754
|
+
ctx.footprint('Http Call Done');
|
|
712
755
|
}
|
|
713
756
|
};
|
|
714
757
|
|
|
758
|
+
function shouldIgnoreError(statusCode, url, statusCodeIgnore, statusIgnoreSet) {
|
|
759
|
+
if (statusCodeIgnore) {
|
|
760
|
+
var ignoreCodes = statusCodeIgnore.split(',');
|
|
761
|
+
if (ignoreCodes.includes(String(statusCode))) {
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (statusIgnoreSet) {
|
|
767
|
+
var ignoreSet = statusIgnoreSet.split(',');
|
|
768
|
+
var setValue = url + ":" + statusCode;
|
|
769
|
+
if (ignoreSet.includes(setValue)) {
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
|
|
715
777
|
exports.HttpObserver = HttpObserver;
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
Logger = require('../logger'),
|
|
23
23
|
conf = require('../conf/configure'),
|
|
24
24
|
DateUtil = require('../util/dateutil'),
|
|
25
|
-
Buffer = require('buffer').Buffer
|
|
25
|
+
Buffer = require('buffer').Buffer,
|
|
26
|
+
MessageStep = require("../step/message-step");
|
|
26
27
|
|
|
27
28
|
var MariaObserver = function (agent) {
|
|
28
29
|
this.agent = agent;
|
|
@@ -101,6 +102,21 @@ var queryHook = function (dbc_hash, agent) {
|
|
|
101
102
|
|
|
102
103
|
if(args[0]) {
|
|
103
104
|
try{
|
|
105
|
+
if (conf.trace_sql_error_stack && conf.trace_sql_error_depth) {
|
|
106
|
+
var traceDepth = conf.trace_sql_error_depth;
|
|
107
|
+
|
|
108
|
+
var errorStack = args[0].stack.split("\n");
|
|
109
|
+
if (errorStack.length > traceDepth) {
|
|
110
|
+
errorStack = errorStack.slice(0, traceDepth + 1);
|
|
111
|
+
}
|
|
112
|
+
var errorStackString = errorStack.join("\n");
|
|
113
|
+
var error_stack_step = new MessageStep();
|
|
114
|
+
error_stack_step.hash = HashUtil.hashFromString("ERROR STACK");
|
|
115
|
+
error_stack_step.start_time = ctx.getElapsedTime();
|
|
116
|
+
error_stack_step.desc = errorStackString;
|
|
117
|
+
DataTextAgent.MESSAGE.add(error_stack_step.hash, "ERROR STACK");
|
|
118
|
+
ctx.profile.push(error_stack_step);
|
|
119
|
+
}
|
|
104
120
|
if(conf._is_trace_ignore_err_cls_contains === true && args[0].code.indexOf(conf.trace_ignore_err_cls_contains) < 0){
|
|
105
121
|
sql_step.error = StatError.addError( 'Maria-'+args[0].code, args[0].message || 'Maria error', ctx.service_hash, TextTypes.SQL, step.hash); /*long*/
|
|
106
122
|
if (ctx.error.isZero()) { ctx.error = sql_step.error; }
|