Comparing version 0.4.86 to 0.4.87
@@ -190,3 +190,2 @@ /** | ||
}; | ||
}; | ||
@@ -274,2 +273,5 @@ | ||
remote_addr = req.headers[configIpHeaderKey] || req.connection.remoteAddress || "0.0.0.0"; | ||
if(remote_addr.includes(',')) { | ||
remote_addr = remote_addr.split(',')[0].trim(); | ||
} | ||
remote_addr=IPUtil.checkIp4(remote_addr); | ||
@@ -276,0 +278,0 @@ ctx.remoteIp = IPUtil.stringToInt(remote_addr); |
@@ -8,18 +8,22 @@ /** | ||
var TraceContextManager = require('../trace/trace-context-manager'), | ||
SocketStep = require('../step/socket-step'), | ||
conf = require('../conf/configure'), | ||
IPUtil = require('../util/iputil'), | ||
Logger = require('../logger'); | ||
SocketStep = require('../step/socket-step'), | ||
conf = require('../conf/configure'), | ||
IPUtil = require('../util/iputil'), | ||
Logger = require('../logger'); | ||
var NetObserver = function(agent){ | ||
var NetObserver = function (agent) { | ||
this.agent = agent; | ||
this.packages = ['net']; | ||
this.packages = ['net', 'dgram']; | ||
}; | ||
NetObserver.prototype.inject = function (mod, moduleName) { | ||
if(mod.__whatap_observe__) { return; } | ||
if (mod.__whatap_observe__) { | ||
return; | ||
} | ||
mod.__whatap_observe__ = true; | ||
Logger.initPrint("NetObserver"); | ||
if ( conf.trace_background_socket_enabled === false ) { return; } | ||
if (conf.trace_background_socket_enabled === false) { | ||
return; | ||
} | ||
@@ -32,18 +36,17 @@ var self = this; | ||
var ctx = lctx.context; | ||
if(ctx == null){ | ||
if (ctx == null) { | ||
return; | ||
} | ||
var info, host, port; | ||
if(args.length > 0){ | ||
info = args[0]; | ||
host = info.host; | ||
port = info.port; | ||
} | ||
if(port == undefined){ | ||
var host, port; | ||
if (args.length > 1) { | ||
host = args[1]; | ||
port = args[0]; | ||
} | ||
if (port == undefined) { | ||
lctx.step = null; | ||
return; | ||
return; | ||
} | ||
ctx.socket_connecting=true; | ||
ctx.socket_connecting = true; | ||
ctx.footprint('Socket Connecting: ' + host+':'+port); | ||
ctx.footprint('Socket Connecting: ' + host + ':' + port); | ||
@@ -54,7 +57,2 @@ var step = new SocketStep(); | ||
step.port = port; | ||
// obj.on('lookup', function(err, ip, addressType){ | ||
// if(step != null) { | ||
// step.ipaddr = new Buffer(IPUtil.stringToBytes(ip)); | ||
// } | ||
// }); | ||
ctx.profile.push(step); | ||
@@ -66,6 +64,6 @@ lctx.step = step; | ||
var step = lctx.step; | ||
if(ctx==null || step == null){ | ||
return; | ||
if (ctx == null || step == null) { | ||
return; | ||
} | ||
ctx.socket_connecting=false; | ||
ctx.socket_connecting = false; | ||
step.elapsed = ctx.getElapsedTime() - step.start_time; | ||
@@ -75,4 +73,44 @@ ctx.footprint('Socket Connecting Done'); | ||
); | ||
aop.both(mod, ['createSocket'], | ||
function (obj, args, lctx) { | ||
var ctx = lctx.context; | ||
if (ctx == null) { | ||
return; | ||
} | ||
}, | ||
function (obj, args, ret, lctx) { | ||
var ctx = lctx.context; | ||
if (ctx == null) { | ||
return; | ||
} | ||
aop.after(ret, 'send', function (_obj, _args, _ret, _lctx) { | ||
var host, port; | ||
if (_args.length > 2) { | ||
host = _args[2]; | ||
port = _args[1]; | ||
} | ||
if (port == undefined) { | ||
lctx.step = null; | ||
return; | ||
} | ||
ctx.socket_connecting = true; | ||
ctx.footprint('Socket Connecting: ' + host + ':' + port); | ||
var step = new SocketStep(); | ||
step.start_time = ctx.getElapsedTime(); | ||
step.ipaddr = Buffer.from(IPUtil.stringToBytes(host)); | ||
step.port = port; | ||
ctx.socket_connecting = false; | ||
step.elapsed = ctx.getElapsedTime() - step.start_time; | ||
ctx.profile.push(step); | ||
ctx.footprint('Socket Connecting Done'); | ||
}) | ||
} | ||
); | ||
}; | ||
exports.NetObserver = NetObserver; |
{ | ||
"name": "whatap", | ||
"homepage": "http://www.whatap.io", | ||
"version": "0.4.86", | ||
"releaseDate": "20240104", | ||
"version": "0.4.87", | ||
"releaseDate": "20240111", | ||
"description": "Monitoring and Profiling Service", | ||
@@ -7,0 +7,0 @@ "main": "index.js", |
952776
20467