whatap 0.4.80 → 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.
@@ -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
- "_trace_mtrace_caller_key": str("mtrace_caller_key","x-wtap-mst"),
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
- "apdex_time_4t": num('apdex_time_4t', 1200 * 4),
194
- "debug_apdex_enabled": bool('debug_apdex_enabled', false),
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 = undefined;
44
- var configRefererKey = undefined;
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
- var ctx = initCtx(req, res);
99
- if( ctx == null ) { return callback(req, res); }
100
-
101
- PluginLoaderManager.do('httpservicestart', ctx, req, res);
102
- if(trace_origin_url === true){
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
- aop.after(res, 'end', function(obj, args) {
114
- if(TraceContextManager.resume(ctx._id) == null) { return; }
115
- PluginLoaderManager.do('httpserviceend', ctx, req, res);
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
- ctx.isStaticContents = isStatic(req.url);
118
- ctx.http_method = req.method;
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
- self.__endTransaction(null, ctx, req, res);
134
- });
135
+ aop.after(res, 'end', function(obj, args) {
136
+ if(ctx == null) { return; }
137
+ PluginLoaderManager.do('httpserviceend', ctx, req, res);
135
138
 
136
- try {
137
- return callback.apply(this, arguments);
138
- } catch (e) {
139
- Logger.printError("WHATAP-606", 'Hooking request failed..', e, false);
140
- self.__endTransaction(e, ctx, req, res);
141
- throw e;
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; }
@@ -211,6 +245,7 @@ function initCtx(req, res) {
211
245
  DataTextAgent.HTTP_DOMAIN.add(ctx.http_host_hash, ctx.http_host);
212
246
  }
213
247
 
248
+ ctx.originUrl = req.url;
214
249
  ctx.start_malloc = ResourceProfile.getUsedHeapSize();
215
250
  ctx.start_cpu = ResourceProfile.getCPUTime();
216
251
  ctx.http_method = req.method;
@@ -229,7 +264,7 @@ function initCtx(req, res) {
229
264
  MeterUsers.add(ctx.userid);
230
265
  break;
231
266
  case 2:
232
- // MeterUsers.add(ctx.userid);
267
+ // MeterUsers.add(ctx.userid);
233
268
  break;
234
269
  case 3:
235
270
  ctx.userid = UserIdUtil.getUserId(req, res, 0);
@@ -239,9 +274,9 @@ function initCtx(req, res) {
239
274
 
240
275
  } catch (e) {
241
276
  }
242
- /************************************/
277
+ /************************************/
243
278
  /* Header / param Trace */
244
- /************************************/
279
+ /************************************/
245
280
  var header_enabled = false;
246
281
  if(conf.profile_http_header_enabled === true && req.headers) {
247
282
  header_enabled = true;
@@ -250,7 +285,7 @@ function initCtx(req, res) {
250
285
  header_enabled = false;
251
286
  }
252
287
  }
253
-
288
+
254
289
  if(header_enabled) {
255
290
  var step = new MessageStep();
256
291
  step.hash = HashUtil.hashFromString("HTTP-HEADERS");
@@ -259,9 +294,9 @@ function initCtx(req, res) {
259
294
  DataTextAgent.MESSAGE.add(step.hash, "HTTP-HEADERS");
260
295
  ctx.profile.push(step);
261
296
  }
262
- /************************************/
297
+ /************************************/
263
298
  /* Multi Server Transaction Trace */
264
- /************************************/
299
+ /************************************/
265
300
  if(conf.mtrace_enabled) {
266
301
  var poid=req.headers['x-wtap-po'];
267
302
  if (poid != null) {
@@ -282,6 +317,13 @@ function initCtx(req, res) {
282
317
  ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1));
283
318
  } else {
284
319
  ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1, z));
320
+
321
+ var z2 = mt_caller.indexOf(',', z + 1);
322
+ if (z2 < 0) {
323
+ ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1));
324
+ } else {
325
+ ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1, z2));
326
+ }
285
327
  }
286
328
  }
287
329
  }
@@ -300,7 +342,7 @@ function initCtx(req, res) {
300
342
  }
301
343
  }
302
344
  }
303
-
345
+
304
346
  return ctx;
305
347
  };
306
348
 
@@ -330,7 +372,16 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
330
372
  DataTextAgent.MESSAGE.add(step.hash, "HTTP-PARAMETERS");
331
373
  ctx.profile.push(step);
332
374
  }
333
-
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
+
334
385
  if(error) {
335
386
  TraceContextManager.end(ctx != null ? ctx._id : null);
336
387
  ctx = null;
@@ -368,6 +419,7 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
368
419
  wtx.cpuTime = ResourceProfile.getCPUTime() - ctx.start_cpu;
369
420
  wtx.malloc = ResourceProfile.getUsedHeapSize()-ctx.start_malloc;
370
421
  if(wtx.malloc < 0) { wtx.malloc = 0; }
422
+ wtx.originUrl = ctx.originUrl;
371
423
 
372
424
  wtx.seq = ctx.txid;
373
425
  wtx.sqlCount = ctx.sql_count;
@@ -380,7 +432,7 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
380
432
  if (ctx.error.isZero() === false) {
381
433
  wtx.error = ctx.error;
382
434
  wtx.errorLevel = EventLevel.WARNING;
383
- }
435
+ }
384
436
  wtx.userAgent = ctx.userAgent;
385
437
  wtx.referer = ctx.referer;
386
438
 
@@ -393,21 +445,22 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
393
445
  wtx.mtid=ctx.mtid;
394
446
  wtx.mdepth=ctx.mdepth;
395
447
  wtx.mcaller=ctx.mcaller_txid;
448
+ wtx.mcallerStepId = ctx.mcaller_stepId;
396
449
  wtx.mcaller_pcode = ctx.mcaller_pcode;
397
450
  wtx.mcaller_okind = ctx.mcaller_okind;
398
451
  wtx.mcaller_oid = ctx.mcaller_oid;
399
452
 
400
- MeterService.add(wtx.service, wtx.elapsed,
453
+ MeterService.add(wtx.service, wtx.elapsed,
401
454
  wtx.errorLevel, ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
402
455
 
403
456
  profile.oid = SecurityMaster.OID;
404
457
  profile.service = wtx;
405
- if(Boolean(conf.reqlog_enabled) == true) {
458
+ if(Boolean(conf.reqlog_enabled) == true) {
406
459
  ctx.endTime = wtx.endTime;
407
460
  ctx.elapsed = wtx.elapsed;
408
461
  RequestLog.setRecord(ctx);
409
462
  }
410
- //duplicated executed... so end() first
463
+ //duplicated executed... so end() first
411
464
  TraceContextManager.end(ctx._id);
412
465
  setTimeout(function () {
413
466
  DataProfileAgent.sendProfile(ctx, profile, false);
@@ -428,14 +481,14 @@ function transferPOID(ctx) {
428
481
  if (transfer_poid)
429
482
  return transfer_poid;
430
483
  transfer_poid=Hexa32.toString32(SecurityMaster.PCODE)+','
431
- +Hexa32.toString32(SecurityMaster.OKIND)+','+Hexa32.toString32(SecurityMaster.OID);
484
+ +Hexa32.toString32(SecurityMaster.OKIND)+','+Hexa32.toString32(SecurityMaster.OID);
432
485
  return transfer_poid;
433
486
  }
434
487
 
435
488
  function transferMTID_CALLERTX(ctx) {
436
489
  if (ctx.transfer_id)
437
490
  return ctx.transfer_id;
438
- 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);
439
492
  ctx.transfer_id = x;
440
493
  return ctx.transfer_id;
441
494
  }
@@ -515,7 +568,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
515
568
 
516
569
  aop.before(mod.Server.prototype, ['on', 'addListener'], function (obj, args) {
517
570
  if(args[0] !== 'request') {return;}
518
-
571
+
519
572
  args[args.length-1] = self.__createTransactionObserver(args[args.length-1],
520
573
  moduleName === 'https', obj);
521
574
  });
@@ -535,7 +588,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
535
588
  if(moduleName === 'http' && args[0].__isHttps) {
536
589
  isHttpsRepeat = true;
537
590
  }
538
-
591
+
539
592
  if(!isHttpsRepeat) {
540
593
  try {
541
594
  if(args[0].method === 'OPTION') {
@@ -543,12 +596,12 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
543
596
  }
544
597
 
545
598
  var dataConsumption = false;
546
-
599
+
547
600
  if(args.length > 0) {
548
601
  var info = args[0];
549
-
550
- interTxTraceAutoOn(ctx);
551
-
602
+
603
+ interTxTraceAutoOn(ctx);
604
+
552
605
  if(conf.mtrace_enabled){
553
606
  if(info.headers){
554
607
  info.headers['x-wtap-po']=transferPOID(ctx);
@@ -560,8 +613,8 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
560
613
  if(conf.stat_mtrace_enabled){
561
614
  info.headers[conf._trace_mtrace_spec_key1]=transferSPEC_URL(ctx);
562
615
  }
563
- if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
564
- 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);
565
618
  }
566
619
 
567
620
  }
@@ -569,11 +622,11 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
569
622
  ctx.httpc_host = info.host || info.hostname || '';
570
623
  ctx.httpc_port = info.port || -1;
571
624
  }
572
- ctx.footprint('Http Call Start');
625
+ ctx.footprint('Http Call Start');
573
626
 
574
627
  if (ctx.httpc_port < 0) { ctx.httpc_port = 80 };
575
628
 
576
- } catch(e) {
629
+ } catch(e) {
577
630
  return Logger.printError('WHATAP-852', 'Http Repeat ', e, true);
578
631
  }
579
632
 
@@ -608,12 +661,12 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
608
661
 
609
662
  ret.on('response', function(response){
610
663
  var statusCode = response.statusCode;
611
- if(statusCode >= 400){
664
+ if(transaction_status_error_enable && statusCode >= 400){
612
665
  if (step.error.isZero()) {
613
666
  step.error = StatError.addError(statusCode, response.statusMessage , ctx.service_hash,
614
667
  TextTypes.HTTPC_URL, step.url);
615
- if (ctx.error.isZero()) {
616
- ctx.error = step.error;
668
+ if (ctx.error.isZero()) {
669
+ ctx.error = step.error;
617
670
  ctx.statusCode = statusCode;
618
671
  ctx.statusMessage = response.statusMessage;
619
672
  }
@@ -623,11 +676,11 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
623
676
  ret.on('error', function(err) {
624
677
  if (TraceContextManager.resume(ctx._id) == null) { return; }
625
678
 
626
- if (step.error.isZero()) {
679
+ if (transaction_status_error_enable && step.error.isZero()) {
627
680
  step.error = StatError.addError(err.code, err.message, ctx.service_hash,
628
681
  TextTypes.HTTPC_URL, step.url);
629
- if (ctx.error.isZero()) {
630
- ctx.error = step.error;
682
+ if (ctx.error.isZero()) {
683
+ ctx.error = step.error;
631
684
  ctx.statusCode = err.code;
632
685
  ctx.statusMessage = err.message;
633
686
  }
@@ -656,7 +709,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
656
709
  }
657
710
  }
658
711
  });
659
-
712
+
660
713
  aop.before(ret, 'end', function (obj, args) {
661
714
  ctx.active_httpc_hash = step.url;
662
715
  ctx.profile.push(step);
@@ -670,13 +723,13 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
670
723
  TraceContextManager.resume(ctx._id);
671
724
  endHttpc(ctx, step);
672
725
  });
673
-
726
+
674
727
  socket.on('timeout', function () {
675
728
  if (TraceContextManager.resume(ctx._id) == null) { return; }
676
729
  if (step.error.isZero()) {
677
730
  var msgObj = { 'class': 'Timeout', 'msg': 'Timeout' };
678
731
  step.error = StatError.addError('Timeout','Timeout', ctx.service_hash);
679
- if (ctx.error.isZero()) {
732
+ if (transaction_status_error_enable && ctx.error.isZero()) {
680
733
  ctx.error = step.error;
681
734
  ctx.statusCode = 'Timeout';
682
735
  ctx.statusMessage = 'Timeout';
@@ -688,7 +741,7 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
688
741
  });
689
742
  });
690
743
 
691
- function endHttpc(ctx, step) {
744
+ function endHttpc(ctx, step) {
692
745
  if(ctx == null || step == null) { return; }
693
746
 
694
747
  step.elapsed = ctx.getElapsedTime() - step.start_time;
@@ -698,8 +751,27 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
698
751
 
699
752
  MeterHttpC.add(step.host, step.elapsed, step.error.isZero()===false);
700
753
  StatHttpc.addHttpcTime(ctx.service_hash, step.url, step.host, step.port, step.elapsed, step.error.isZero()===false);
701
- ctx.footprint('Http Call Done');
754
+ ctx.footprint('Http Call Done');
702
755
  }
703
756
  };
704
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
+
705
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; }