whatap 0.5.21 → 0.5.23

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.
@@ -194,6 +194,15 @@ HttpObserver.prototype.__createTransactionObserver = function(callback, isHttps,
194
194
  ctx.profile.add(step);
195
195
  }
196
196
 
197
+ // res.on('aborted', () => {
198
+ // self.__endTransaction(null, ctx, req, res)
199
+ // })
200
+
201
+ res.on('close', () => {
202
+ // 강제로 종료할 경우
203
+ self.__endTransaction(null, ctx, req, res)
204
+ });
205
+
197
206
  aop.after(res, 'end', function(obj, args) {
198
207
  if(ctx == null) { return; }
199
208
  PluginLoaderManager.do('httpserviceend', ctx, req, res);
@@ -537,6 +546,8 @@ function initCtx(req, res) {
537
546
  };
538
547
 
539
548
  HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
549
+ if(ctx == null || TraceContextManager.isExist(ctx._id) === false) { return; }
550
+
540
551
  var param_enabled = false;
541
552
  if(conf.profile_http_parameter_enabled === true) {
542
553
  param_enabled = true;
@@ -591,7 +602,7 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
591
602
  return;
592
603
  }
593
604
 
594
- if(ctx == null || TraceContextManager.isExist(ctx._id) === false) { return; }
605
+ // if(ctx == null || TraceContextManager.isExist(ctx._id) === false) { return; }
595
606
 
596
607
  if(ctx.isStaticContents !== true && conf._trace_ignore_url_set[ctx.service_hash]){
597
608
  ctx.isStaticContents = true;
@@ -779,12 +790,20 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
779
790
  });
780
791
  });
781
792
 
782
- aop.before(mod.Server.prototype, ['on', 'addListener'], function (obj, args) {
783
- if(args[0] !== 'request') {return;}
784
-
785
- args[args.length-1] = self.__createTransactionObserver(args[args.length-1],
786
- moduleName === 'https', obj);
787
- });
793
+ shimmer.wrap(mod.Server.prototype, 'emit', function wrapEmit(originalEmit) {
794
+ return function wrappedEmit(eventName, ...args) {
795
+ if (eventName !== 'request') {
796
+ return originalEmit.apply(this, [eventName, ...args]);
797
+ }
798
+ let [req, res] = args;
799
+ return self.__createTransactionObserver(
800
+ (req, res) => originalEmit.call(this, eventName, req, res),
801
+ moduleName === 'https',
802
+ this
803
+ )(req, res);
804
+ };
805
+ }
806
+ );
788
807
 
789
808
  if( conf.getProperty('httpc_enabled', true) === false ) { return; }
790
809
 
@@ -60,6 +60,7 @@ MongoObserver.prototype.inject = function( mod, moduleName ) {
60
60
  self.agent.aop.before(mod.Collection.prototype, command, function (obj, args) {
61
61
  var ctx = TraceContextManager.getCurrentContext();
62
62
  if(ctx == null) { return; }
63
+ if(ctx && ctx.__mongoose_traced__) { return; }
63
64
 
64
65
  ctx.footprint('Mongodb Command Start: ' + command );
65
66
  var sql_step;
@@ -94,6 +95,7 @@ MongoObserver.prototype.inject = function( mod, moduleName ) {
94
95
  self.agent.aop.both(mod.Collection.prototype, command, function (obj, args, lctx) {
95
96
  var ctx = lctx.context;
96
97
  if(ctx == null) { return; }
98
+ if(ctx && ctx.__mongoose_traced__) { return; }
97
99
 
98
100
  ctx.footprint('Mongodb Command Start: ' + command );
99
101
  var sql_step;
@@ -192,6 +194,7 @@ MongoObserver.prototype.inject = function( mod, moduleName ) {
192
194
  //args[0] where, args[1] set
193
195
  var ctx = TraceContextManager.getCurrentContext();
194
196
  if(ctx == null) {return;}
197
+ if(ctx && ctx.__mongoose_traced__) { return; }
195
198
 
196
199
  ctx.footprint('Mongodb Command Start: '+command);
197
200
  var sql_step;
@@ -239,6 +242,7 @@ MongoObserver.prototype.inject = function( mod, moduleName ) {
239
242
  //args[0] where
240
243
  var ctx = TraceContextManager.getCurrentContext();
241
244
  if(ctx == null) { return; }
245
+ if(ctx && ctx.__mongoose_traced__) { return; }
242
246
 
243
247
  ctx.footprint('Mongodb Command Start: '+command);
244
248
  var sql_step;
@@ -278,6 +282,7 @@ MongoObserver.prototype.inject = function( mod, moduleName ) {
278
282
  self.agent.aop.both(mod.Collection.prototype, command, function (obj, args) {
279
283
  var ctx = TraceContextManager.getCurrentContext();
280
284
  if(ctx == null) { return; }
285
+ if(ctx && ctx.__mongoose_traced__) { return; }
281
286
 
282
287
  ctx.footprint('Mongodb Command Start: '+command);
283
288
  var sql_step;