whatap 0.5.1 → 0.5.3
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 +2 -0
- package/lib/counter/counter-manager.js +12 -7
- package/lib/observers/http-observer.js +115 -143
- package/lib/observers/maria-observer.js +180 -271
- package/lib/observers/mssql-observer.js +11 -17
- package/lib/observers/mysql-observer.js +10 -12
- package/lib/observers/pgsql-observer.js +192 -212
- package/lib/trace/trace-httpc.js +26 -0
- package/lib/trace/trace-sql.js +45 -0
- package/package.json +2 -2
|
@@ -112,6 +112,7 @@ var ConfigDefault = {
|
|
|
112
112
|
|
|
113
113
|
"profile_error_sql_time_max": num("profile_error_sql_time_max", 30000),
|
|
114
114
|
"profile_error_step_enabled": bool('profile_error_step_enabled', true),
|
|
115
|
+
"profile_error_httpc_time_max": num("profile_error_httpc_time_max", 10000),
|
|
115
116
|
"hook_direct_patch_classes": "",
|
|
116
117
|
|
|
117
118
|
"log_rotation_enabled": bool('log_rotation_enabled',true),
|
|
@@ -266,6 +267,7 @@ var ConfigDefault = {
|
|
|
266
267
|
"grpc_profile_ignore_method": bool("grpc_profile_ignore_method", true),
|
|
267
268
|
|
|
268
269
|
"oname_port_postfix_enabled": bool("oname_port_postfix_enabled", false),
|
|
270
|
+
"ignore_http_lost_connection": bool("ignore_http_lost_connection", false)
|
|
269
271
|
};
|
|
270
272
|
|
|
271
273
|
ConfigDefault._hook_method_ignore_prefix = ConfigDefault.hook_method_ignore_prefixes.split(',');
|
|
@@ -26,8 +26,7 @@ var CounterPack = require('../pack/counter-pack'),
|
|
|
26
26
|
DateUtil = require('./../util/dateutil'),
|
|
27
27
|
KubeClient = require('../kube/kube-client'),
|
|
28
28
|
KubeUtil = require('../util/kube-util'),
|
|
29
|
-
Logger = require('../logger')
|
|
30
|
-
Long = require('long');
|
|
29
|
+
Logger = require('../logger');
|
|
31
30
|
|
|
32
31
|
function CounterManager(agent) {
|
|
33
32
|
this.agent = agent;
|
|
@@ -90,11 +89,17 @@ CounterManager.prototype.process = function (tasks) {
|
|
|
90
89
|
var ctx = enumer.nextElement();
|
|
91
90
|
if (ctx.getElapsedTime() > conf.profile_max_time) {
|
|
92
91
|
//TraceContextManager.end(ctx._id);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
if(conf.getProperty("ignore_http_lost_connection", false) === true){
|
|
93
|
+
Logger.print("WHATAP-072", "Lost Connection was ignored, " + ctx._id, false);
|
|
94
|
+
TraceContextManager.end(ctx._id);
|
|
95
|
+
ctx = null;
|
|
96
|
+
}else{
|
|
97
|
+
// var obj = TraceContextManager.resume(ctx._id);
|
|
98
|
+
TraceContextManager.addStep("Lost Connection","", ctx);
|
|
99
|
+
//ctx.status = 5;
|
|
100
|
+
//ctx.error = StatError.addError(500, "Lost Connection", ctx.service_hash);
|
|
101
|
+
TraceContextManager.endTrace(ctx);
|
|
102
|
+
}
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -40,6 +40,8 @@ var TraceContextManager = require('../trace/trace-context-manager'),
|
|
|
40
40
|
IntKeyLinkedMap = require("../util/intkey-linkedmap");
|
|
41
41
|
const ParamSecurity = require("../util/paramsecurity");
|
|
42
42
|
const {Buffer} = require("buffer");
|
|
43
|
+
const shimmer = require('../core/shimmer');
|
|
44
|
+
const TraceHttpc = require('../trace/trace-httpc');
|
|
43
45
|
|
|
44
46
|
var _exts=new Set([".css",".js",".png", ".htm", ".html", ".gif", ".jpg", ".css", ".txt", ".ico"]);
|
|
45
47
|
|
|
@@ -199,17 +201,14 @@ HttpObserver.prototype.__createTransactionObserver = function(callback, isHttps,
|
|
|
199
201
|
ctx.status = Math.floor(obj.statusCode / 100);
|
|
200
202
|
|
|
201
203
|
// 에러가 발생했지만 스택수집안했을 경우
|
|
202
|
-
if (transaction_status_error_enable && ctx.status >= 4
|
|
203
|
-
ctx.error
|
|
204
|
-
ctx.service_hash);
|
|
204
|
+
if (transaction_status_error_enable && ctx.status >= 4) {
|
|
205
|
+
if(ctx.error.isZero())
|
|
206
|
+
ctx.error = StatError.addError(obj.statusCode, obj.statusMessage, ctx.service_hash);
|
|
205
207
|
ctx.statusCode = obj.statusCode;
|
|
206
|
-
ctx.
|
|
208
|
+
ctx.statusTitle = obj.statusMessage;
|
|
209
|
+
ctx.statusMessage = ctx.error_message;
|
|
207
210
|
}
|
|
208
211
|
|
|
209
|
-
var requestPath = '';
|
|
210
|
-
if(req.route && req.route.path)
|
|
211
|
-
requestPath = req.route.path;
|
|
212
|
-
|
|
213
212
|
var shouldEndTransaction = shouldEndCurrentTransaction(not_found_ignore, ctx, res, req.route ? req.route.path : '');
|
|
214
213
|
if (shouldEndTransaction) {
|
|
215
214
|
self.__endTransaction(null, ctx, req, res);
|
|
@@ -469,10 +468,11 @@ HttpObserver.prototype.__endTransaction = function(error, ctx, req, res) {
|
|
|
469
468
|
|
|
470
469
|
if(profile_error_step_enabled && ctx.statusMessage){
|
|
471
470
|
var step = new MessageStep();
|
|
472
|
-
|
|
471
|
+
var title = ctx.statusTitle ? ctx.statusTitle : "EXCEPTION";
|
|
472
|
+
step.hash = HashUtil.hashFromString(title);
|
|
473
473
|
step.start_time = ctx.getElapsedTime();
|
|
474
474
|
step.desc = ctx.statusMessage;
|
|
475
|
-
DataTextAgent.MESSAGE.add(step.hash,
|
|
475
|
+
DataTextAgent.MESSAGE.add(step.hash, title);
|
|
476
476
|
ctx.profile.push(step);
|
|
477
477
|
}
|
|
478
478
|
|
|
@@ -667,112 +667,102 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
667
667
|
moduleName === 'https', obj);
|
|
668
668
|
});
|
|
669
669
|
|
|
670
|
-
if( conf.httpc_enabled === false ) { return; }
|
|
671
|
-
|
|
672
|
-
aop.both(mod, 'request',
|
|
673
|
-
function (obj, args, lctx) {
|
|
674
|
-
var ctx = lctx.context;
|
|
675
|
-
if (ctx == null || (args[0].host == null && args[0].hostname == null) ) { return; } // for axios
|
|
670
|
+
if( conf.getProperty('httpc_enabled', true) === false ) { return; }
|
|
676
671
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
672
|
+
shimmer.wrap(mod, 'request', function (original) {
|
|
673
|
+
return function wrappedRequest(options, callback) {
|
|
674
|
+
var ctx = TraceContextManager.getCurrentContext();
|
|
675
|
+
if(!ctx || (!options.host && !options.hostname)){
|
|
676
|
+
return original.apply(this, arguments);
|
|
680
677
|
}
|
|
681
678
|
|
|
682
|
-
|
|
683
|
-
|
|
679
|
+
var isHttpRepeat = false;
|
|
680
|
+
if(moduleName === 'https'){
|
|
681
|
+
options.__isHttps = true;
|
|
682
|
+
}
|
|
683
|
+
if(moduleName === 'http' && options.__isHttps){
|
|
684
|
+
isHttpRepeat = true;
|
|
684
685
|
}
|
|
685
686
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if(args[0].method === 'OPTION') {
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
var dataConsumption = false;
|
|
693
|
-
|
|
694
|
-
if(args.length > 0) {
|
|
695
|
-
var info = args[0];
|
|
696
|
-
|
|
697
|
-
interTxTraceAutoOn(ctx);
|
|
698
|
-
|
|
699
|
-
if(conf.mtrace_enabled){
|
|
700
|
-
if(info.headers){
|
|
701
|
-
info.headers['x-wtap-po']=transferPOID(ctx);
|
|
702
|
-
}else{
|
|
703
|
-
info.headers={
|
|
704
|
-
'x-wtap-po': transferPOID(ctx)
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
if(conf.stat_mtrace_enabled){
|
|
708
|
-
info.headers[conf._trace_mtrace_spec_key1]=transferSPEC_URL(ctx);
|
|
709
|
-
}
|
|
710
|
-
if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
|
|
711
|
-
info.headers[conf._trace_mtrace_caller_key]=transferMTID_CALLERTX(ctx);
|
|
712
|
-
}
|
|
687
|
+
var step = new HttpStepX();
|
|
688
|
+
step.start_time = ctx.getElapsedTime();
|
|
713
689
|
|
|
690
|
+
if(!isHttpRepeat){
|
|
691
|
+
if(options.method === 'OPTION'){
|
|
692
|
+
return original.apply(this, arguments);
|
|
693
|
+
}
|
|
694
|
+
try{
|
|
695
|
+
interTxTraceAutoOn(ctx);
|
|
696
|
+
if(conf.getProperty('mtrace_enabled', false)){
|
|
697
|
+
if(options.headers){
|
|
698
|
+
options.headers['x-wtap-po'] = transferPOID(ctx);
|
|
699
|
+
}else{
|
|
700
|
+
options.headers = {'x-wtap-po': transferPOID(ctx)};
|
|
701
|
+
}
|
|
702
|
+
if(conf.stat_mtrace_enabled){
|
|
703
|
+
options.headers[conf._trace_mtrace_spec_key1]=transferSPEC_URL(ctx);
|
|
704
|
+
}
|
|
705
|
+
if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
|
|
706
|
+
options.headers[conf._trace_mtrace_caller_key]=transferMTID_CALLERTX(ctx);
|
|
714
707
|
}
|
|
715
|
-
ctx.httpc_url = info.path || '/';
|
|
716
|
-
ctx.httpc_host = info.host || info.hostname || '';
|
|
717
|
-
ctx.httpc_port = info.port || -1;
|
|
718
708
|
}
|
|
709
|
+
|
|
710
|
+
ctx.httpc_url = options.path || '/';
|
|
711
|
+
ctx.httpc_host = options.host || options.hostname || '';
|
|
712
|
+
ctx.httpc_port = options.port || -1;
|
|
713
|
+
|
|
719
714
|
ctx.footprint('Http Call Start');
|
|
720
715
|
|
|
721
716
|
if (ctx.httpc_port < 0) { ctx.httpc_port = 80 };
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
return
|
|
717
|
+
}catch (e) {
|
|
718
|
+
Logger.printError('WHATAP-852', 'Http Repeat ', e, true);
|
|
719
|
+
return original.apply(this, arguments);
|
|
725
720
|
}
|
|
721
|
+
}else{
|
|
722
|
+
return original.apply(this, arguments);
|
|
723
|
+
}
|
|
726
724
|
|
|
727
|
-
|
|
728
|
-
|
|
725
|
+
var wrappedCallback;
|
|
726
|
+
if (typeof callback === 'function') {
|
|
727
|
+
wrappedCallback = function(response) {
|
|
728
|
+
if (TraceContextManager.resume(ctx._id) === null) {
|
|
729
|
+
return callback.apply(this, arguments);
|
|
730
|
+
}
|
|
729
731
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
response.on('end', function() {
|
|
733
|
+
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
734
|
+
step.url = HashUtil.hashFromString(ctx.httpc_url);
|
|
735
|
+
DataTextAgent.HTTPC_URL.add(step.url, ctx.httpc_url);
|
|
736
|
+
step.host = HashUtil.hashFromString(ctx.httpc_host);
|
|
737
|
+
DataTextAgent.HTTPC_HOST.add(step.host, ctx.httpc_host);
|
|
738
|
+
step.port = ctx.httpc_port;
|
|
739
|
+
|
|
740
|
+
if (response.statusCode >= 400 && transaction_status_error_enable) {
|
|
741
|
+
step.error = StatError.addError(response.statusCode, response.statusMessage,
|
|
742
|
+
ctx.service_hash, TextTypes.HTTPC_URL, step.url);
|
|
743
|
+
if (ctx.error.isZero()) {
|
|
744
|
+
ctx.error = step.error;
|
|
745
|
+
ctx.statusCode = response.statusCode;
|
|
746
|
+
ctx.statusMessage = response.statusMessage;
|
|
747
|
+
}
|
|
734
748
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
aop.before(res, 'resume', function() {
|
|
740
|
-
dataConsumption = true;
|
|
749
|
+
|
|
750
|
+
ctx.active_httpc_hash = step.url;
|
|
751
|
+
ctx.profile.push(step);
|
|
752
|
+
endHttpc(ctx, step);
|
|
741
753
|
});
|
|
742
754
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
},
|
|
748
|
-
function (obj, args, ret, lctx) {
|
|
749
|
-
if(moduleName === 'http' && args[0].__isHttps) {
|
|
750
|
-
return;
|
|
755
|
+
return callback.apply(this, arguments);
|
|
756
|
+
};
|
|
751
757
|
}
|
|
752
758
|
|
|
753
|
-
var
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
ret.on('response', function(response){
|
|
758
|
-
var statusCode = response.statusCode;
|
|
759
|
-
if(transaction_status_error_enable && statusCode >= 400){
|
|
760
|
-
if (step.error.isZero()) {
|
|
761
|
-
step.error = StatError.addError(statusCode, response.statusMessage , ctx.service_hash,
|
|
762
|
-
TextTypes.HTTPC_URL, step.url);
|
|
763
|
-
if (ctx.error.isZero()) {
|
|
764
|
-
ctx.error = step.error;
|
|
765
|
-
ctx.statusCode = statusCode;
|
|
766
|
-
ctx.statusMessage = response.statusMessage;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
})
|
|
771
|
-
ret.on('error', function(err) {
|
|
772
|
-
if (TraceContextManager.resume(ctx._id) == null) { return; }
|
|
759
|
+
var req = original.apply(this, [options, wrappedCallback]);
|
|
760
|
+
|
|
761
|
+
req.on('error', function (err) {
|
|
762
|
+
if (TraceContextManager.resume(ctx._id) === null) { return; }
|
|
773
763
|
ctx.is_httpc_error = true;
|
|
774
764
|
|
|
775
|
-
if (transaction_status_error_enable && step.error.isZero()
|
|
765
|
+
if (transaction_status_error_enable && step.error.isZero()) {
|
|
776
766
|
step.error = StatError.addError(err.code, err.message, ctx.service_hash,
|
|
777
767
|
TextTypes.HTTPC_URL, step.url);
|
|
778
768
|
if (ctx.error.isZero()) {
|
|
@@ -785,63 +775,45 @@ HttpObserver.prototype.inject = function( mod, moduleName ) {
|
|
|
785
775
|
endHttpc(ctx, step);
|
|
786
776
|
});
|
|
787
777
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
778
|
+
shimmer.wrap(req, 'write', function (original) {
|
|
779
|
+
return function wrappedWrite() {
|
|
780
|
+
try {
|
|
781
|
+
if (conf.getProperty('profile_httpc_parameter_enabled', true)) {
|
|
782
|
+
if (arguments && arguments[0]) {
|
|
783
|
+
var bodyData;
|
|
784
|
+
|
|
785
|
+
if (typeof arguments[0] === 'object' && !(arguments[0] instanceof Buffer)) {
|
|
786
|
+
bodyData = JSON.stringify(arguments[0]);
|
|
787
|
+
}
|
|
788
|
+
if (arguments[0] instanceof Buffer) {
|
|
789
|
+
bodyData = arguments[0].toString('utf8');
|
|
790
|
+
}
|
|
791
|
+
if(bodyData){
|
|
792
|
+
var step = new MessageStep();
|
|
793
|
+
step.hash = HashUtil.hashFromString("HTTPC-REQUEST-BODY");
|
|
794
|
+
step.start_time = ctx.getElapsedTime();
|
|
795
|
+
step.desc = bodyData;
|
|
796
|
+
DataTextAgent.MESSAGE.add(step.hash, "HTTPC-REQUEST-BODY");
|
|
797
|
+
ctx.profile.push(step);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
} catch (e) {
|
|
802
|
+
Logger.printError('WHATAP-615', 'HTTP Write hook failed', e, false);
|
|
805
803
|
}
|
|
804
|
+
return original.apply(this, arguments);
|
|
806
805
|
}
|
|
807
806
|
});
|
|
808
807
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
ret.on('socket', function(socket) {
|
|
815
|
-
// socket reuse chk
|
|
816
|
-
if(conf.setSocketChk(socket) == false) {
|
|
817
|
-
aop.before(socket, 'end', function (obj, args) {
|
|
818
|
-
if(ctx == null) { return; }
|
|
819
|
-
TraceContextManager.resume(ctx._id);
|
|
820
|
-
endHttpc(ctx, step);
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
socket.on('timeout', function () {
|
|
824
|
-
if (TraceContextManager.resume(ctx._id) == null) { return; }
|
|
825
|
-
is_ignore_error = true;
|
|
826
|
-
// if (step.error.isZero()) {
|
|
827
|
-
// var msgObj = { 'class': 'Timeout', 'msg': 'Timeout' };
|
|
828
|
-
// step.error = StatError.addError('Timeout','Timeout', ctx.service_hash);
|
|
829
|
-
// if (transaction_status_error_enable && ctx.error.isZero()) {
|
|
830
|
-
// ctx.error = step.error;
|
|
831
|
-
// ctx.statusCode = 'Timeout';
|
|
832
|
-
// ctx.statusMessage = 'Timeout';
|
|
833
|
-
// }
|
|
834
|
-
// }
|
|
835
|
-
// endHttpc(ctx, step);
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
});
|
|
808
|
+
return req;
|
|
809
|
+
}
|
|
810
|
+
});
|
|
840
811
|
|
|
841
812
|
function endHttpc(ctx, step) {
|
|
842
813
|
if(ctx == null || step == null) { return; }
|
|
843
814
|
|
|
844
815
|
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
816
|
+
TraceHttpc.isSlowHttpc(ctx, step);
|
|
845
817
|
|
|
846
818
|
ctx.httpc_count++;
|
|
847
819
|
ctx.httpc_time += step.elapsed;
|