whatap 0.4.86 → 0.4.87

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.
@@ -187,7 +187,6 @@ HttpObserver.prototype.__createTransactionObserver = function(callback, isHttps,
187
187
  }
188
188
  });
189
189
  };
190
-
191
190
  };
192
191
 
193
192
  function isStatic(u){
@@ -270,6 +269,9 @@ function initCtx(req, res) {
270
269
  var remote_addr;
271
270
  try {
272
271
  remote_addr = req.headers[configIpHeaderKey] || req.connection.remoteAddress || "0.0.0.0";
272
+ if(remote_addr.includes(',')) {
273
+ remote_addr = remote_addr.split(',')[0].trim();
274
+ }
273
275
  remote_addr=IPUtil.checkIp4(remote_addr);
274
276
  ctx.remoteIp = IPUtil.stringToInt(remote_addr);
275
277
  switch (conf.trace_user_using_type || 3) {
@@ -5,22 +5,26 @@
5
5
  */
6
6
 
7
7
  var TraceContextManager = require('../trace/trace-context-manager'),
8
- SocketStep = require('../step/socket-step'),
9
- conf = require('../conf/configure'),
10
- IPUtil = require('../util/iputil'),
11
- Logger = require('../logger');
8
+ SocketStep = require('../step/socket-step'),
9
+ conf = require('../conf/configure'),
10
+ IPUtil = require('../util/iputil'),
11
+ Logger = require('../logger');
12
12
 
13
13
 
14
- var NetObserver = function(agent){
14
+ var NetObserver = function (agent) {
15
15
  this.agent = agent;
16
- this.packages = ['net'];
16
+ this.packages = ['net', 'dgram'];
17
17
  };
18
18
 
19
19
  NetObserver.prototype.inject = function (mod, moduleName) {
20
- if(mod.__whatap_observe__) { return; }
20
+ if (mod.__whatap_observe__) {
21
+ return;
22
+ }
21
23
  mod.__whatap_observe__ = true;
22
24
  Logger.initPrint("NetObserver");
23
- if ( conf.trace_background_socket_enabled === false ) { return; }
25
+ if (conf.trace_background_socket_enabled === false) {
26
+ return;
27
+ }
24
28
 
25
29
  var self = this;
26
30
  var aop = self.agent.aop;
@@ -28,46 +32,80 @@ NetObserver.prototype.inject = function (mod, moduleName) {
28
32
  aop.both(mod.Socket.prototype, ['connect'],
29
33
  function (obj, args, lctx) {
30
34
  var ctx = lctx.context;
31
- if(ctx == null){
35
+ if (ctx == null) {
32
36
  return;
33
- }
34
- var info, host, port;
35
- if(args.length > 0){
36
- info = args[0];
37
- host = info.host;
38
- port = info.port;
39
37
  }
40
- if(port == undefined){
38
+ var host, port;
39
+ if (args.length > 1) {
40
+ host = args[1];
41
+ port = args[0];
42
+ }
43
+ if (port == undefined) {
41
44
  lctx.step = null;
42
- return;
45
+ return;
43
46
  }
44
- ctx.socket_connecting=true;
47
+ ctx.socket_connecting = true;
45
48
 
46
- ctx.footprint('Socket Connecting: ' + host+':'+port);
49
+ ctx.footprint('Socket Connecting: ' + host + ':' + port);
47
50
 
48
51
  var step = new SocketStep();
49
52
  step.start_time = ctx.getElapsedTime();
50
53
  step.ipaddr = Buffer.from(IPUtil.stringToBytes(host));
51
54
  step.port = port;
52
- // obj.on('lookup', function(err, ip, addressType){
53
- // if(step != null) {
54
- // step.ipaddr = new Buffer(IPUtil.stringToBytes(ip));
55
- // }
56
- // });
57
55
  ctx.profile.push(step);
58
56
  lctx.step = step;
59
57
  },
60
58
  function (obj, args, ret, lctx) {
61
59
  var ctx = lctx.context;
62
60
  var step = lctx.step;
63
- if(ctx==null || step == null){
64
- return;
61
+ if (ctx == null || step == null) {
62
+ return;
65
63
  }
66
- ctx.socket_connecting=false;
64
+ ctx.socket_connecting = false;
67
65
  step.elapsed = ctx.getElapsedTime() - step.start_time;
68
66
  ctx.footprint('Socket Connecting Done');
69
67
  }
70
68
  );
69
+
70
+ aop.both(mod, ['createSocket'],
71
+ function (obj, args, lctx) {
72
+ var ctx = lctx.context;
73
+ if (ctx == null) {
74
+ return;
75
+ }
76
+ },
77
+ function (obj, args, ret, lctx) {
78
+ var ctx = lctx.context;
79
+ if (ctx == null) {
80
+ return;
81
+ }
82
+ aop.after(ret, 'send', function (_obj, _args, _ret, _lctx) {
83
+ var host, port;
84
+ if (_args.length > 2) {
85
+ host = _args[2];
86
+ port = _args[1];
87
+ }
88
+ if (port == undefined) {
89
+ lctx.step = null;
90
+ return;
91
+ }
92
+ ctx.socket_connecting = true;
93
+
94
+ ctx.footprint('Socket Connecting: ' + host + ':' + port);
95
+
96
+ var step = new SocketStep();
97
+ step.start_time = ctx.getElapsedTime();
98
+ step.ipaddr = Buffer.from(IPUtil.stringToBytes(host));
99
+ step.port = port;
100
+
101
+ ctx.socket_connecting = false;
102
+ step.elapsed = ctx.getElapsedTime() - step.start_time;
103
+ ctx.profile.push(step);
104
+
105
+ ctx.footprint('Socket Connecting Done');
106
+ })
107
+ }
108
+ );
71
109
  };
72
110
 
73
111
  exports.NetObserver = NetObserver;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "whatap",
3
3
  "homepage": "http://www.whatap.io",
4
- "version": "0.4.86",
5
- "releaseDate": "20240104",
4
+ "version": "0.4.87",
5
+ "releaseDate": "20240111",
6
6
  "description": "Monitoring and Profiling Service",
7
7
  "main": "index.js",
8
8
  "scripts": {},