whatap 1.0.1 → 1.0.2
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/README.md +32 -78
- package/lib/conf/conf-sys-mon.js +101 -0
- package/lib/conf/config-default.js +10 -3
- package/lib/conf/configure.js +369 -349
- package/lib/conf/license.js +1 -1
- package/lib/control/cmd-config.js +24 -0
- package/lib/control/control-handler.js +367 -0
- package/lib/control/packagectr-helper.js +34 -3
- package/lib/core/agent.js +176 -882
- package/lib/core/interceptor.js +6 -6
- package/lib/core/request-agent.js +27 -0
- package/lib/core/shimmer.js +82 -36
- package/lib/counter/counter-manager.js +79 -8
- package/lib/counter/meter/meter-activex.js +67 -0
- package/lib/counter/meter/meter-httpc.js +57 -0
- package/lib/counter/meter/meter-resource.js +9 -0
- package/lib/counter/meter/meter-service.js +168 -0
- package/lib/counter/meter/meter-socket.io.js +51 -0
- package/lib/counter/meter/meter-sql.js +71 -0
- package/lib/counter/meter/meter-users.js +58 -0
- package/lib/counter/meter.js +183 -0
- package/lib/counter/task/activetransaction.js +68 -17
- package/lib/counter/task/agentinfo.js +107 -0
- package/lib/{system → counter/task}/gc-action.js +27 -74
- package/lib/counter/task/gcstat.js +34 -0
- package/lib/counter/task/heapmem.js +25 -0
- package/lib/counter/task/httpc.js +76 -0
- package/lib/counter/task/metering-info.js +125 -0
- package/lib/counter/task/proc-cpu.js +29 -0
- package/lib/counter/task/realtimeuser.js +31 -0
- package/lib/counter/task/res/systemECSTask.js +39 -0
- package/lib/counter/task/res/systemKubeTask.js +53 -0
- package/lib/counter/task/res/util/awsEcsClientThread.js +218 -0
- package/lib/counter/task/res/util/linuxProcStatUtil.js +14 -0
- package/lib/counter/task/res-sys-cpu.js +62 -0
- package/lib/counter/task/service.js +202 -0
- package/lib/counter/task/socketio.js +30 -0
- package/lib/counter/task/sql.js +105 -0
- package/lib/counter/task/systemperf.js +43 -0
- package/lib/data/datapack-sender.js +289 -0
- package/lib/data/dataprofile-agent.js +162 -0
- package/lib/data/datatext-agent.js +135 -0
- package/lib/data/event-level.js +15 -0
- package/lib/data/test.js +49 -0
- package/lib/data/zipprofile.js +197 -0
- package/lib/env/constants.js +21 -0
- package/lib/error/error-handler.js +437 -0
- package/lib/io/data-inputx.js +13 -3
- package/lib/io/data-outputx.js +268 -206
- package/lib/kube/kube-client.js +144 -0
- package/lib/lang/text-types.js +58 -0
- package/lib/logger.js +6 -6
- package/lib/logsink/line-log-util.js +87 -0
- package/lib/logsink/line-log.js +12 -0
- package/lib/logsink/log-sender.js +78 -0
- package/lib/logsink/log-tracer.js +40 -0
- package/lib/logsink/sender-util.js +56 -0
- package/lib/logsink/zip/zip-send.js +177 -0
- package/lib/net/netflag.js +55 -0
- package/lib/net/receiver.js +66 -0
- package/lib/net/security-master.js +139 -20
- package/lib/net/sender.js +141 -0
- package/lib/net/tcp-return.js +18 -0
- package/lib/net/tcp-session.js +286 -0
- package/lib/net/tcpreq-client-proxy.js +70 -0
- package/lib/net/tcprequest-mgr.js +58 -0
- package/lib/observers/apollo-server-observer.js +33 -27
- package/lib/observers/cluster-observer.js +22 -0
- package/lib/observers/express-observer.js +215 -0
- package/lib/observers/file-observer.js +184 -0
- package/lib/observers/global-observer.js +155 -80
- package/lib/observers/grpc-observer.js +336 -0
- package/lib/observers/http-observer.js +666 -236
- package/lib/observers/maria-observer.js +204 -362
- package/lib/observers/memcached-observer.js +56 -0
- package/lib/observers/mongo-observer.js +317 -0
- package/lib/observers/mongodb-observer.js +169 -226
- package/lib/observers/mongoose-observer.js +518 -323
- package/lib/observers/mssql-observer.js +177 -418
- package/lib/observers/mysql-observer.js +342 -449
- package/lib/observers/mysql2-observer.js +396 -358
- package/lib/observers/net-observer.js +77 -0
- package/lib/observers/oracle-observer.js +559 -384
- package/lib/observers/pgsql-observer.js +231 -489
- package/lib/observers/prisma-observer.js +303 -92
- package/lib/observers/process-observer.js +79 -35
- package/lib/observers/promise-observer.js +31 -0
- package/lib/observers/redis-observer.js +166 -331
- package/lib/observers/schedule-observer.js +67 -0
- package/lib/observers/socket.io-observer.js +226 -187
- package/lib/observers/stream-observer.js +19 -0
- package/lib/observers/thrift-observer.js +197 -0
- package/lib/observers/websocket-observer.js +175 -301
- package/lib/pack/activestack-pack.js +55 -0
- package/lib/pack/apenum.js +8 -0
- package/lib/pack/counter-pack.js +3 -0
- package/lib/pack/errorsnap-pack.js +69 -0
- package/lib/pack/event-pack.js +54 -0
- package/lib/pack/hitmap-pack.js +63 -0
- package/lib/pack/hitmap-pack1.js +152 -0
- package/lib/pack/log-sink-pack.js +14 -52
- package/lib/pack/netstat.js +15 -0
- package/lib/pack/otype.js +7 -0
- package/lib/pack/profile-pack.js +49 -0
- package/lib/pack/realtimeuser-pack.js +41 -0
- package/lib/pack/stat-general-pack.js +96 -0
- package/lib/pack/staterror-pack.js +120 -0
- package/lib/pack/stathttpc-pack.js +66 -0
- package/lib/pack/stathttpc-rec.js +78 -0
- package/lib/pack/statremote-pack.js +46 -0
- package/lib/pack/statservice-pack.js +63 -0
- package/lib/pack/statservice-pack1.js +88 -0
- package/lib/pack/statservice-rec.js +292 -0
- package/lib/pack/statservice-rec_dep.js +151 -0
- package/lib/pack/statsql-pack.js +69 -0
- package/lib/pack/statsql-rec.js +100 -0
- package/lib/pack/statuseragent-pack.js +44 -0
- package/lib/pack/tagcount-pack.js +4 -4
- package/lib/pack/tagctr.js +15 -0
- package/lib/pack/text-pack.js +50 -0
- package/lib/pack/time-count.js +25 -0
- package/lib/pack/websocket.js +15 -0
- package/lib/pack/zip-pack.js +70 -0
- package/lib/pii/pii-item.js +31 -0
- package/lib/pii/pii-mask.js +174 -0
- package/lib/plugin/plugin-loadermanager.js +57 -0
- package/lib/plugin/plugin.js +75 -0
- package/lib/service/tx-record.js +332 -0
- package/lib/stat/stat-error.js +116 -0
- package/lib/stat/stat-httpc.js +98 -0
- package/lib/stat/stat-remote-ip.js +46 -0
- package/lib/stat/stat-remote-ipurl.js +88 -0
- package/lib/stat/stat-sql.js +113 -0
- package/lib/stat/stat-tranx.js +58 -0
- package/lib/stat/stat-tx-caller.js +160 -0
- package/lib/stat/stat-tx-domain.js +111 -0
- package/lib/stat/stat-tx-referer.js +112 -0
- package/lib/stat/stat-useragent.js +48 -0
- package/lib/stat/timingsender.js +76 -0
- package/lib/step/activestack-step.js +38 -0
- package/lib/step/dbc-step.js +36 -0
- package/lib/step/http-stepx.js +67 -0
- package/lib/step/message-step.js +40 -0
- package/lib/step/method-stepx.js +45 -0
- package/lib/step/resultset-step.js +40 -0
- package/lib/step/securemsg-step.js +44 -0
- package/lib/step/socket-step.js +46 -0
- package/lib/step/sql-stepx.js +68 -0
- package/lib/step/sqlxtype.js +16 -0
- package/lib/step/step.js +66 -0
- package/lib/step/stepenum.js +54 -0
- package/lib/topology/link.js +63 -0
- package/lib/topology/nodeinfo.js +123 -0
- package/lib/topology/status-detector.js +111 -0
- package/lib/trace/trace-context-manager.js +113 -25
- package/lib/trace/trace-context.js +21 -7
- package/lib/trace/trace-httpc.js +17 -11
- package/lib/trace/trace-sql.js +29 -21
- package/lib/util/anylist.js +103 -0
- package/lib/util/cardinality/hyperloglog.js +106 -0
- package/lib/util/cardinality/murmurhash.js +31 -0
- package/lib/util/cardinality/registerset.js +75 -0
- package/lib/util/errordata.js +21 -0
- package/lib/util/escape-literal-sql.js +5 -5
- package/lib/util/hashutil.js +18 -18
- package/lib/util/iputil_x.js +527 -0
- package/lib/util/keygen.js +0 -3
- package/lib/util/kube-util.js +73 -0
- package/lib/util/linkedset.js +1 -2
- package/lib/util/nodeutil.js +2 -1
- package/lib/util/paramsecurity.js +80 -0
- package/lib/util/pre-process.js +13 -0
- package/lib/util/process-seq.js +166 -0
- package/lib/util/property-util.js +36 -0
- package/lib/util/request-queue.js +70 -0
- package/lib/util/requestdouble-queue.js +72 -0
- package/lib/util/resourceprofile.js +157 -0
- package/lib/util/stop-watch.js +30 -0
- package/lib/util/system-util.js +10 -0
- package/lib/util/userid-util.js +57 -0
- package/lib/value/map-value.js +3 -2
- package/package.json +9 -4
- package/whatap.conf +1 -4
- package/agent/darwin/arm64/whatap_nodejs +0 -0
- package/agent/linux/amd64/whatap_nodejs +0 -0
- package/agent/linux/arm64/whatap_nodejs +0 -0
- package/build.txt +0 -4
- package/lib/observers/ioredis-observer.js +0 -294
- package/lib/udp/async_sender.js +0 -119
- package/lib/udp/index.js +0 -17
- package/lib/udp/packet_enum.js +0 -52
- package/lib/udp/packet_queue.js +0 -69
- package/lib/udp/packet_type_enum.js +0 -33
- package/lib/udp/param_def.js +0 -72
- package/lib/udp/udp_session.js +0 -336
- package/lib/util/sql-util.js +0 -178
- package/lib/util/trace-helper.js +0 -91
- package/lib/util/transfer.js +0 -58
package/lib/conf/license.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var Configure = require('./../conf/configure');
|
|
9
|
+
var MapValue = require('./../value/map-value');
|
|
10
|
+
var PropertyUtil = require('./../util/property-util');
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
update: function(m /* MapValue */){
|
|
14
|
+
|
|
15
|
+
},
|
|
16
|
+
readConfig: function(){
|
|
17
|
+
var props = Configure.getCustomProps();
|
|
18
|
+
var mv = new MapValue();
|
|
19
|
+
for(var k in props){
|
|
20
|
+
mv.putString(k, props[k]);
|
|
21
|
+
}
|
|
22
|
+
return mv;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var os = require('os');
|
|
8
|
+
var PackageCtrHelper = require('./packagectr-helper'),
|
|
9
|
+
RequestQueue = require('../util/request-queue'),
|
|
10
|
+
PackEnum = require('../pack/packenum'),
|
|
11
|
+
ParamDef = require('../net/paramdef'),
|
|
12
|
+
Configure = require('../conf/configure'),
|
|
13
|
+
MapValue = require('../value/map-value'),
|
|
14
|
+
DateUtil = require('../util/dateutil'),
|
|
15
|
+
TextValue = require('../value/text-value'),
|
|
16
|
+
ResourceProfile = require('../util/resourceprofile'),
|
|
17
|
+
TraceContextManager = require('../trace/trace-context-manager'),
|
|
18
|
+
Logger = require('../logger'),
|
|
19
|
+
StatusDetector = require('../topology/status-detector'),
|
|
20
|
+
BlobValue = require('../value/blob-value'),
|
|
21
|
+
conf = require('../conf/configure');
|
|
22
|
+
|
|
23
|
+
var ControlHandler = function () {
|
|
24
|
+
this.queue = new RequestQueue(100);
|
|
25
|
+
this._dataPackSender = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ControlHandler.prototype.add = function (p /* Pack */) {
|
|
29
|
+
this.process(p);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
ControlHandler.prototype.process = async function (p) {
|
|
33
|
+
switch (p.getPackType()) {
|
|
34
|
+
case PackEnum.PARAMETER:
|
|
35
|
+
await this.handle(p);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
Logger.printError('WHATAP-203', 'Unknown pack received ' + p, new Error('Unknown pack'));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
ControlHandler.prototype.handle = async function (p) {
|
|
43
|
+
var self = this;
|
|
44
|
+
if (!this._dataPackSender) {
|
|
45
|
+
this._dataPackSender = require('../data/datapack-sender');
|
|
46
|
+
}
|
|
47
|
+
switch (p.id) {
|
|
48
|
+
case ParamDef.CONFIGURE_GET:
|
|
49
|
+
var m = Configure.readCustomConfig();
|
|
50
|
+
p.setMapValue(m);
|
|
51
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
52
|
+
break;
|
|
53
|
+
case ParamDef.GET_ACTIVE_STACK:
|
|
54
|
+
break;
|
|
55
|
+
case ParamDef.GET_ACTIVE_TRANSACTION_DETAIL:
|
|
56
|
+
try {
|
|
57
|
+
var threadId = p.getNumber("thread_id");
|
|
58
|
+
var profile = p.getLong("profile");
|
|
59
|
+
var m = getCurrentStackDetail(threadId, profile);
|
|
60
|
+
p.putValue("detail", m);
|
|
61
|
+
|
|
62
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
63
|
+
} catch (e) {
|
|
64
|
+
Logger.printError('WHATAP-010', 'Active Transaction Detail', e, true);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case ParamDef.GET_ACTIVE_TRANSACTION_LIST:
|
|
68
|
+
try {
|
|
69
|
+
var m = getActiveTxList();
|
|
70
|
+
p.putValue("active", m);
|
|
71
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
72
|
+
} catch (e) {
|
|
73
|
+
Logger.printError('WHATAP-203', 'Get active transaction list ', e, true);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case ParamDef.HEAP_HISTO:
|
|
77
|
+
|
|
78
|
+
break;
|
|
79
|
+
case ParamDef.LOADED_CLASS_LIST:
|
|
80
|
+
try {
|
|
81
|
+
var packageList = PackageCtrHelper.getLoadedPackageList();
|
|
82
|
+
var mv = new MapValue();
|
|
83
|
+
var indexLv = mv.newList("index");
|
|
84
|
+
var nameLv = mv.newList("name");
|
|
85
|
+
var typeLv = mv.newList("type");
|
|
86
|
+
var superClassLv = mv.newList("superClass");
|
|
87
|
+
var interfacesLv = mv.newList("interfaces");
|
|
88
|
+
var resourceLv = mv.newList("resource");
|
|
89
|
+
|
|
90
|
+
for (var i = 0; i < packageList.length; i++) {
|
|
91
|
+
var pkg = packageList[i];
|
|
92
|
+
indexLv.addLong(i);
|
|
93
|
+
nameLv.addString(pkg);
|
|
94
|
+
typeLv.addString(pkg);
|
|
95
|
+
superClassLv.addString(pkg);
|
|
96
|
+
interfacesLv.addString(pkg);
|
|
97
|
+
resourceLv.addString(pkg);
|
|
98
|
+
}
|
|
99
|
+
p.putValue("classlist", mv);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
p.put("error", e.toString());
|
|
102
|
+
}
|
|
103
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case ParamDef.LOADED_CLASS_DETAIL:
|
|
107
|
+
var pkgName = p.getText("classname");
|
|
108
|
+
try {
|
|
109
|
+
var dependencies = PackageCtrHelper.getPackageDetail(pkgName);
|
|
110
|
+
var subPkgNameAndVersion = '';
|
|
111
|
+
for (var k in dependencies) {
|
|
112
|
+
var dep = dependencies[k];
|
|
113
|
+
subPkgNameAndVersion += k + ": " + dep + "\n";
|
|
114
|
+
}
|
|
115
|
+
p.put("class", subPkgNameAndVersion);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
p.put("error", e.toString());
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case ParamDef.LOADED_CLASS_REDEFINE:
|
|
121
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
122
|
+
break;
|
|
123
|
+
case ParamDef.NODE_MODULE_DEPENDENCY:
|
|
124
|
+
|
|
125
|
+
var mv = new MapValue();
|
|
126
|
+
try {
|
|
127
|
+
var dependencies = PackageCtrHelper.getDependencies();
|
|
128
|
+
var keys = Object.keys(dependencies);
|
|
129
|
+
|
|
130
|
+
for (var i = 0; i < keys.length; i++) {
|
|
131
|
+
mv.putString(keys[i], JSON.stringify(dependencies[keys[i]]));
|
|
132
|
+
}
|
|
133
|
+
p.putValue("module", mv);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
Logger.printError('WHATAP-003', 'Node Module Dependency ', e, true);
|
|
136
|
+
}
|
|
137
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
138
|
+
break;
|
|
139
|
+
case ParamDef.GET_ENV:
|
|
140
|
+
try {
|
|
141
|
+
var mv = new MapValue();
|
|
142
|
+
let ignore_env_variable = conf.getProperty('ignore_env_variable_set', '');
|
|
143
|
+
let ignore_env_variable_set = ignore_env_variable ? new Set(ignore_env_variable.split(',').map(item => item.trim())) : new Set();
|
|
144
|
+
for (var k in process.env) {
|
|
145
|
+
if(ignore_env_variable_set.has(k)) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
var v = process.env[k];
|
|
149
|
+
mv.putString(k, v);
|
|
150
|
+
}
|
|
151
|
+
p.putValue("env", mv);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
p.putValue("error", e.toString());
|
|
154
|
+
}
|
|
155
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case ParamDef.SYSTEM_GC:
|
|
159
|
+
try {
|
|
160
|
+
var mem1 = process.memoryUsage();
|
|
161
|
+
var total1 = mem1.heapTotal;
|
|
162
|
+
var used1 = mem1.heapUsed;
|
|
163
|
+
|
|
164
|
+
if (global && global.gc && typeof global.gc === 'function') {
|
|
165
|
+
global.gc();
|
|
166
|
+
} else {
|
|
167
|
+
Logger.printError('WHATAP-177', 'Garbage collection unavailable. Pass --expose-gc '
|
|
168
|
+
+ 'when launching node to enable forced garbage collection.', new Error());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var mem2 = process.memoryUsage();
|
|
172
|
+
var total2 = mem2.heapTotal;
|
|
173
|
+
var used2 = mem2.heapUsed;
|
|
174
|
+
|
|
175
|
+
var mv = new MapValue();
|
|
176
|
+
mv.putLong("before-t", total1);
|
|
177
|
+
mv.putLong("before-u", used1);
|
|
178
|
+
mv.putLong("after-t", total2);
|
|
179
|
+
mv.putLong("after-u", used2);
|
|
180
|
+
p.putValue("gc", mv);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
p.putValue("error", e.toString());
|
|
183
|
+
}
|
|
184
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
185
|
+
break;
|
|
186
|
+
case ParamDef.SET_CONFIG:
|
|
187
|
+
try {
|
|
188
|
+
var mv = p.getValue('config');
|
|
189
|
+
var en = mv.keys();
|
|
190
|
+
var props = {};
|
|
191
|
+
while(en.hasMoreElements()){
|
|
192
|
+
var key = en.nextElement();
|
|
193
|
+
var val = mv.getText(key);
|
|
194
|
+
props[key] = val
|
|
195
|
+
}
|
|
196
|
+
Configure.saveProperty(props);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
p.putValue("error", e.toString())
|
|
199
|
+
}
|
|
200
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
201
|
+
break;
|
|
202
|
+
|
|
203
|
+
case ParamDef.LOADED_CLASS_DETAIL:
|
|
204
|
+
|
|
205
|
+
break;
|
|
206
|
+
|
|
207
|
+
case ParamDef.OPEN_SOCKET_LIST:
|
|
208
|
+
|
|
209
|
+
break;
|
|
210
|
+
|
|
211
|
+
case ParamDef.RESET_STRING_SENT_MARK:
|
|
212
|
+
break;
|
|
213
|
+
case ParamDef.AGENT_LOG_LIST:
|
|
214
|
+
var o = Logger.getLogFiles();
|
|
215
|
+
if (o !== null) {
|
|
216
|
+
p.putValue("files", o);
|
|
217
|
+
}
|
|
218
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
219
|
+
break;
|
|
220
|
+
|
|
221
|
+
case ParamDef.AGENT_LOG_READ:
|
|
222
|
+
var file = p.getText("file");
|
|
223
|
+
var endpos = p.getNumber("pos");
|
|
224
|
+
var length = p.getNumber("length"); // 최대 16k 만 가능함...
|
|
225
|
+
length = Math.min(length, 8000);
|
|
226
|
+
if (endpos == 0) {
|
|
227
|
+
endpos += length;
|
|
228
|
+
}
|
|
229
|
+
Logger.read(file, endpos, length, function (before, next, text) {
|
|
230
|
+
p.putLong("before", before);
|
|
231
|
+
p.putLong("next", next);
|
|
232
|
+
p.putString("text", text);
|
|
233
|
+
self._dataPackSender.sendResponseHide(p.getResponse());
|
|
234
|
+
});
|
|
235
|
+
break;
|
|
236
|
+
case ParamDef.GET_TOPOLOGY:
|
|
237
|
+
try {
|
|
238
|
+
const node = await new StatusDetector().process();
|
|
239
|
+
if (node) {
|
|
240
|
+
p.putValue("node", new BlobValue(node.toBytes()));
|
|
241
|
+
}
|
|
242
|
+
this._dataPackSender.sendResponseHide(p.getResponse());
|
|
243
|
+
} catch (e) {
|
|
244
|
+
Logger.printError('WHATAP-203', 'Node Module Dependency ', e, true);
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function getActiveTxList() {
|
|
251
|
+
var out = new MapValue()
|
|
252
|
+
var time = out.newList("time");
|
|
253
|
+
var tx_hash = out.newList("tx_hash");
|
|
254
|
+
var tx_name = out.newList("tx_name");
|
|
255
|
+
var profile = out.newList("profile");
|
|
256
|
+
var ip = out.newList("ip");
|
|
257
|
+
|
|
258
|
+
var userid = out.newList("userid");
|
|
259
|
+
var elapsed = out.newList("elapsed");
|
|
260
|
+
var cputime = out.newList("cputime");
|
|
261
|
+
var malloc = out.newList("malloc");
|
|
262
|
+
var sqlCount = out.newList("sqlCount");
|
|
263
|
+
|
|
264
|
+
var sqlTime = out.newList("sqlTime");
|
|
265
|
+
var httpcCount = out.newList("httpcCount");
|
|
266
|
+
var httpcTime = out.newList("httpcTime");
|
|
267
|
+
var threadId = out.newList("threadId");
|
|
268
|
+
var threadStat = out.newList("threadStat");
|
|
269
|
+
|
|
270
|
+
var act_dbc = out.newList("act_dbc");
|
|
271
|
+
var act_sql = out.newList("act_sql");
|
|
272
|
+
var act_httpc = out.newList("act_httpc");
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
var currentTime = DateUtil.currentTime();
|
|
276
|
+
|
|
277
|
+
//여기서 초기화가 안된 상태인경우가 있음..
|
|
278
|
+
TraceContextManager = require('../trace/trace-context-manager');
|
|
279
|
+
var en = TraceContextManager.getContextEnumeration();
|
|
280
|
+
|
|
281
|
+
while (en.hasMoreElements()) {
|
|
282
|
+
var ctx = en.nextElement();
|
|
283
|
+
if (ctx == null)
|
|
284
|
+
continue;
|
|
285
|
+
|
|
286
|
+
time.addLong(currentTime);
|
|
287
|
+
tx_hash.addLong(ctx.service_hash);
|
|
288
|
+
tx_name.addString(ctx.service_name);
|
|
289
|
+
profile.addLong(ctx.txid);
|
|
290
|
+
ip.addLong(ctx.remoteIp);
|
|
291
|
+
userid.addLong(ctx.userid);
|
|
292
|
+
elapsed.addLong(ctx.getElapsedTime());
|
|
293
|
+
cputime.addLong(ResourceProfile.getCPUTime() - ctx.start_cpu);
|
|
294
|
+
var m = ResourceProfile.getUsedHeapSize() - ctx.start_malloc;
|
|
295
|
+
malloc.addLong(m < 0 ? 0 : m);
|
|
296
|
+
sqlCount.addLong(ctx.sql_count);
|
|
297
|
+
sqlTime.addLong(ctx.sql_time);
|
|
298
|
+
httpcCount.addLong(ctx.httpc_count);
|
|
299
|
+
httpcTime.addLong(ctx.httpc_time);
|
|
300
|
+
threadId.addLong(ctx._id);
|
|
301
|
+
threadStat.addLong(0);
|
|
302
|
+
|
|
303
|
+
act_dbc.addLong(ctx.active_dbc);
|
|
304
|
+
act_sql.addLong(ctx.active_sqlhash);
|
|
305
|
+
|
|
306
|
+
act_httpc.addLong(ctx.active_httpc_hash);
|
|
307
|
+
}
|
|
308
|
+
return out;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getCurrentStackDetail(traceId, txid) {
|
|
312
|
+
var out = new MapValue();
|
|
313
|
+
|
|
314
|
+
var ctx = TraceContextManager.getContext(traceId);
|
|
315
|
+
if (ctx != null && ctx.txid.equals(txid)) {
|
|
316
|
+
out.putLong("time", DateUtil.currentTime());
|
|
317
|
+
out.putLong("tx_hash", ctx.service_hash);
|
|
318
|
+
out.putString("tx_name", ctx.service_name);
|
|
319
|
+
out.putLong("profile", ctx.txid);
|
|
320
|
+
out.putLong("ip", ctx.remoteIp);
|
|
321
|
+
out.putLong("userid", ctx.userToken);
|
|
322
|
+
out.putLong("elapsed", ctx.getElapsedTime());
|
|
323
|
+
out.putLong("sqlCount", ctx.sql_count);
|
|
324
|
+
out.putLong("sqlTime", ctx.sql_time);
|
|
325
|
+
out.putLong("httpcCount", ctx.httpc_count);
|
|
326
|
+
out.putLong("httpcTime", ctx.httpc_time);
|
|
327
|
+
out.putLong("threadId", ctx.thread_id);
|
|
328
|
+
|
|
329
|
+
///////////////////
|
|
330
|
+
if (ctx.http_content_type != null) {
|
|
331
|
+
out.putString("httpContentType", ctx.http_content_type);
|
|
332
|
+
}
|
|
333
|
+
///////////////////
|
|
334
|
+
|
|
335
|
+
if (ctx.active_sqlhash != 0) {
|
|
336
|
+
out.putLong("act_dbc", ctx.active_dbc);
|
|
337
|
+
out.putLong("act_sql", ctx.active_sqlhash);
|
|
338
|
+
}
|
|
339
|
+
if (ctx.active_httpc_hash != 0) {
|
|
340
|
+
out.putLong("act_httpc", ctx.active_httpc_hash);
|
|
341
|
+
out.putLong("act_httpc_host", ctx.httpc_host);
|
|
342
|
+
out.putLong("act_httpc_port", ctx.httpc_port);
|
|
343
|
+
}
|
|
344
|
+
out.putString("method", ctx.http_method);
|
|
345
|
+
|
|
346
|
+
if (ctx.mtid.isZero() === false) {
|
|
347
|
+
out.putLong("mtid", ctx.mtid);
|
|
348
|
+
out.putLong("mdepth", ctx.mdepth);
|
|
349
|
+
out.putLong("mcaller", ctx.mcaller_txid);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// var se = ctx.stack;
|
|
353
|
+
// var stack = out.newList("callstack");
|
|
354
|
+
// for (var i = 0; i < se.length; i++) {
|
|
355
|
+
// stack.addString(se[i]);
|
|
356
|
+
// }
|
|
357
|
+
|
|
358
|
+
var stack = out.newList("callstack");
|
|
359
|
+
stack.addString("Last step time: " + new Date(ctx.last_footprint_time).toString());
|
|
360
|
+
stack.addString("Last step to now: " +(Date.now() - ctx.last_footprint_time) +" ms");
|
|
361
|
+
stack.addString("Last step message: " + ctx.last_footprint_desc);
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
module.exports = new ControlHandler();
|
|
@@ -8,6 +8,8 @@ var fs = require('fs'),
|
|
|
8
8
|
path = require('path');
|
|
9
9
|
|
|
10
10
|
var TraceContextManager = require('../trace/trace-context-manager'),
|
|
11
|
+
DataTextAgent = require('../data/datatext-agent'),
|
|
12
|
+
MethodStep = require('../step/method-stepx'),
|
|
11
13
|
HashUtil = require('../util/hashutil'),
|
|
12
14
|
ArrayUtil = require('../util/array-util'),
|
|
13
15
|
conf = require('../conf/configure'),
|
|
@@ -24,9 +26,38 @@ PackageCtrHelper.addPackage = function(realPath){
|
|
|
24
26
|
loadedPackages[realPath] = require(realPath);
|
|
25
27
|
}
|
|
26
28
|
} catch(e) {
|
|
27
|
-
return Logger.printError("WHATAP-
|
|
29
|
+
return Logger.printError("WHATAP-512", "PackageControler helper", e, false);
|
|
28
30
|
}
|
|
29
31
|
};
|
|
32
|
+
PackageCtrHelper.dynamicHook = function(pkg, realPath, funcName) {
|
|
33
|
+
if(!pkg || !funcName) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var Interceptor = require('../core/interceptor').Interceptor;
|
|
38
|
+
var _aop = new Interceptor(null);
|
|
39
|
+
_aop.both(pkg, funcName,
|
|
40
|
+
function(obj, args, lctx){
|
|
41
|
+
// transaction step
|
|
42
|
+
var ctx = lctx.context;
|
|
43
|
+
if(!ctx) { return; }
|
|
44
|
+
|
|
45
|
+
var msg = realPath + ' ' + funcName;
|
|
46
|
+
var hash = HashUtil.hashFromString(msg);
|
|
47
|
+
var step = new MethodStep();
|
|
48
|
+
DataTextAgent.METHOD.add(hash, msg);
|
|
49
|
+
step.hash = hash;
|
|
50
|
+
step.start_time = ctx.getElapsedTime();
|
|
51
|
+
pkg.__whatap_step__ = step;
|
|
52
|
+
},
|
|
53
|
+
function(obj, args, ret, lctx){
|
|
54
|
+
var ctx = lctx.context;
|
|
55
|
+
if(!ctx) { return; }
|
|
56
|
+
var step = pkg.__whatap_step__;
|
|
57
|
+
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
58
|
+
ctx.profile.add(step);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
30
61
|
PackageCtrHelper.getLoadedPackageList = function(filter){
|
|
31
62
|
return loadedPackageList;
|
|
32
63
|
};
|
|
@@ -51,7 +82,7 @@ PackageCtrHelper.getInstalledPackageList = function(){
|
|
|
51
82
|
}
|
|
52
83
|
return dirs;
|
|
53
84
|
} catch(e) {
|
|
54
|
-
Logger.printError('WHATAP-
|
|
85
|
+
Logger.printError('WHATAP-004', 'Get Installed Package List ', e, true);
|
|
55
86
|
}
|
|
56
87
|
|
|
57
88
|
return [];
|
|
@@ -65,7 +96,7 @@ PackageCtrHelper.getPackageDetail = function(pkg){
|
|
|
65
96
|
packageJson = JSON.parse(packageFile);
|
|
66
97
|
return packageJson.dependencies;
|
|
67
98
|
} catch(e) {
|
|
68
|
-
Logger.printError('WHATAP-
|
|
99
|
+
Logger.printError('WHATAP-005', 'Get Package Detail ', e, true);
|
|
69
100
|
}
|
|
70
101
|
};
|
|
71
102
|
|