whatap 0.5.26 → 1.0.0
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/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 +4 -0
- package/lib/conf/config-default.js +3 -10
- package/lib/conf/configure.js +349 -369
- package/lib/conf/license.js +1 -1
- package/lib/control/packagectr-helper.js +3 -34
- package/lib/core/agent.js +882 -176
- package/lib/core/interceptor.js +6 -6
- package/lib/core/shimmer.js +36 -82
- package/lib/counter/counter-manager.js +8 -79
- package/lib/counter/task/activetransaction.js +17 -68
- package/lib/io/data-inputx.js +3 -13
- package/lib/io/data-outputx.js +206 -268
- package/lib/logger.js +6 -6
- package/lib/net/security-master.js +20 -139
- package/lib/observers/apollo-server-observer.js +27 -33
- package/lib/observers/global-observer.js +80 -155
- package/lib/observers/http-observer.js +236 -666
- package/lib/observers/ioredis-observer.js +294 -0
- package/lib/observers/maria-observer.js +362 -204
- package/lib/observers/mongodb-observer.js +226 -169
- package/lib/observers/mongoose-observer.js +323 -518
- package/lib/observers/mssql-observer.js +418 -177
- package/lib/observers/mysql-observer.js +449 -342
- package/lib/observers/mysql2-observer.js +358 -396
- package/lib/observers/oracle-observer.js +384 -559
- package/lib/observers/pgsql-observer.js +489 -231
- package/lib/observers/prisma-observer.js +92 -303
- package/lib/observers/process-observer.js +35 -79
- package/lib/observers/redis-observer.js +331 -166
- package/lib/observers/socket.io-observer.js +187 -226
- package/lib/observers/websocket-observer.js +301 -175
- package/lib/pack/counter-pack.js +0 -3
- package/lib/pack/log-sink-pack.js +52 -14
- package/lib/pack/tagcount-pack.js +4 -4
- package/lib/{counter/task → system}/gc-action.js +74 -27
- package/lib/trace/trace-context-manager.js +25 -113
- package/lib/trace/trace-context.js +7 -21
- package/lib/trace/trace-httpc.js +11 -17
- package/lib/trace/trace-sql.js +21 -29
- package/lib/udp/async_sender.js +119 -0
- package/lib/udp/index.js +17 -0
- package/lib/udp/packet_enum.js +52 -0
- package/lib/udp/packet_queue.js +69 -0
- package/lib/udp/packet_type_enum.js +33 -0
- package/lib/udp/param_def.js +72 -0
- package/lib/udp/udp_session.js +336 -0
- package/lib/util/escape-literal-sql.js +5 -5
- package/lib/util/hashutil.js +18 -18
- package/lib/util/keygen.js +3 -0
- package/lib/util/linkedset.js +2 -1
- package/lib/util/nodeutil.js +1 -2
- package/lib/util/sql-util.js +178 -0
- package/lib/util/trace-helper.js +91 -0
- package/lib/util/transfer.js +58 -0
- package/lib/value/map-value.js +2 -3
- package/package.json +5 -10
- package/lib/conf/conf-sys-mon.js +0 -101
- package/lib/control/cmd-config.js +0 -24
- package/lib/control/control-handler.js +0 -367
- package/lib/core/request-agent.js +0 -27
- package/lib/counter/meter/meter-activex.js +0 -67
- package/lib/counter/meter/meter-httpc.js +0 -57
- package/lib/counter/meter/meter-resource.js +0 -9
- package/lib/counter/meter/meter-service.js +0 -168
- package/lib/counter/meter/meter-socket.io.js +0 -51
- package/lib/counter/meter/meter-sql.js +0 -71
- package/lib/counter/meter/meter-users.js +0 -58
- package/lib/counter/meter.js +0 -183
- package/lib/counter/task/agentinfo.js +0 -107
- package/lib/counter/task/gcstat.js +0 -34
- package/lib/counter/task/heapmem.js +0 -25
- package/lib/counter/task/httpc.js +0 -76
- package/lib/counter/task/metering-info.js +0 -125
- package/lib/counter/task/proc-cpu.js +0 -29
- package/lib/counter/task/realtimeuser.js +0 -31
- package/lib/counter/task/res/systemECSTask.js +0 -39
- package/lib/counter/task/res/systemKubeTask.js +0 -53
- package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
- package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
- package/lib/counter/task/res-sys-cpu.js +0 -62
- package/lib/counter/task/service.js +0 -202
- package/lib/counter/task/socketio.js +0 -30
- package/lib/counter/task/sql.js +0 -105
- package/lib/counter/task/systemperf.js +0 -43
- package/lib/data/datapack-sender.js +0 -289
- package/lib/data/dataprofile-agent.js +0 -162
- package/lib/data/datatext-agent.js +0 -135
- package/lib/data/event-level.js +0 -15
- package/lib/data/test.js +0 -49
- package/lib/data/zipprofile.js +0 -197
- package/lib/env/constants.js +0 -21
- package/lib/error/error-handler.js +0 -437
- package/lib/kube/kube-client.js +0 -144
- package/lib/lang/text-types.js +0 -58
- package/lib/logsink/line-log-util.js +0 -87
- package/lib/logsink/line-log.js +0 -12
- package/lib/logsink/log-sender.js +0 -78
- package/lib/logsink/log-tracer.js +0 -40
- package/lib/logsink/sender-util.js +0 -56
- package/lib/logsink/zip/zip-send.js +0 -177
- package/lib/net/netflag.js +0 -55
- package/lib/net/receiver.js +0 -66
- package/lib/net/sender.js +0 -141
- package/lib/net/tcp-return.js +0 -18
- package/lib/net/tcp-session.js +0 -286
- package/lib/net/tcpreq-client-proxy.js +0 -70
- package/lib/net/tcprequest-mgr.js +0 -58
- package/lib/observers/cluster-observer.js +0 -22
- package/lib/observers/express-observer.js +0 -215
- package/lib/observers/file-observer.js +0 -184
- package/lib/observers/grpc-observer.js +0 -336
- package/lib/observers/memcached-observer.js +0 -56
- package/lib/observers/mongo-observer.js +0 -317
- package/lib/observers/net-observer.js +0 -77
- package/lib/observers/promise-observer.js +0 -31
- package/lib/observers/schedule-observer.js +0 -67
- package/lib/observers/stream-observer.js +0 -19
- package/lib/observers/thrift-observer.js +0 -197
- package/lib/pack/activestack-pack.js +0 -55
- package/lib/pack/apenum.js +0 -8
- package/lib/pack/errorsnap-pack.js +0 -69
- package/lib/pack/event-pack.js +0 -54
- package/lib/pack/hitmap-pack.js +0 -63
- package/lib/pack/hitmap-pack1.js +0 -152
- package/lib/pack/netstat.js +0 -15
- package/lib/pack/otype.js +0 -7
- package/lib/pack/profile-pack.js +0 -49
- package/lib/pack/realtimeuser-pack.js +0 -41
- package/lib/pack/stat-general-pack.js +0 -96
- package/lib/pack/staterror-pack.js +0 -120
- package/lib/pack/stathttpc-pack.js +0 -66
- package/lib/pack/stathttpc-rec.js +0 -78
- package/lib/pack/statremote-pack.js +0 -46
- package/lib/pack/statservice-pack.js +0 -63
- package/lib/pack/statservice-pack1.js +0 -88
- package/lib/pack/statservice-rec.js +0 -292
- package/lib/pack/statservice-rec_dep.js +0 -151
- package/lib/pack/statsql-pack.js +0 -69
- package/lib/pack/statsql-rec.js +0 -100
- package/lib/pack/statuseragent-pack.js +0 -44
- package/lib/pack/tagctr.js +0 -15
- package/lib/pack/text-pack.js +0 -50
- package/lib/pack/time-count.js +0 -25
- package/lib/pack/websocket.js +0 -15
- package/lib/pack/zip-pack.js +0 -70
- package/lib/pii/pii-item.js +0 -31
- package/lib/pii/pii-mask.js +0 -174
- package/lib/plugin/plugin-loadermanager.js +0 -57
- package/lib/plugin/plugin.js +0 -75
- package/lib/service/tx-record.js +0 -332
- package/lib/stat/stat-error.js +0 -116
- package/lib/stat/stat-httpc.js +0 -98
- package/lib/stat/stat-remote-ip.js +0 -46
- package/lib/stat/stat-remote-ipurl.js +0 -88
- package/lib/stat/stat-sql.js +0 -113
- package/lib/stat/stat-tranx.js +0 -58
- package/lib/stat/stat-tx-caller.js +0 -160
- package/lib/stat/stat-tx-domain.js +0 -111
- package/lib/stat/stat-tx-referer.js +0 -112
- package/lib/stat/stat-useragent.js +0 -48
- package/lib/stat/timingsender.js +0 -76
- package/lib/step/activestack-step.js +0 -38
- package/lib/step/dbc-step.js +0 -36
- package/lib/step/http-stepx.js +0 -67
- package/lib/step/message-step.js +0 -40
- package/lib/step/method-stepx.js +0 -45
- package/lib/step/resultset-step.js +0 -40
- package/lib/step/securemsg-step.js +0 -44
- package/lib/step/socket-step.js +0 -46
- package/lib/step/sql-stepx.js +0 -68
- package/lib/step/sqlxtype.js +0 -16
- package/lib/step/step.js +0 -66
- package/lib/step/stepenum.js +0 -54
- package/lib/topology/link.js +0 -63
- package/lib/topology/nodeinfo.js +0 -123
- package/lib/topology/status-detector.js +0 -111
- package/lib/util/anylist.js +0 -103
- package/lib/util/cardinality/hyperloglog.js +0 -106
- package/lib/util/cardinality/murmurhash.js +0 -31
- package/lib/util/cardinality/registerset.js +0 -75
- package/lib/util/errordata.js +0 -21
- package/lib/util/iputil_x.js +0 -527
- package/lib/util/kube-util.js +0 -73
- package/lib/util/paramsecurity.js +0 -80
- package/lib/util/pre-process.js +0 -13
- package/lib/util/process-seq.js +0 -166
- package/lib/util/property-util.js +0 -36
- package/lib/util/request-queue.js +0 -70
- package/lib/util/requestdouble-queue.js +0 -72
- package/lib/util/resourceprofile.js +0 -157
- package/lib/util/stop-watch.js +0 -30
- package/lib/util/system-util.js +0 -10
- package/lib/util/userid-util.js +0 -57
|
@@ -1,317 +0,0 @@
|
|
|
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 TraceContextManager = require('../trace/trace-context-manager'),
|
|
9
|
-
SqlStepX = require('../step/sql-stepx'),
|
|
10
|
-
DBCStep = require('../step/dbc-step'),
|
|
11
|
-
ResultSetStep = require('../step/resultset-step'),
|
|
12
|
-
HashUtil = require('../util/hashutil'),
|
|
13
|
-
DataTextAgent = require('../data/datatext-agent'),
|
|
14
|
-
Logger = require('../logger');
|
|
15
|
-
|
|
16
|
-
var MongoObserver = function (agent) {
|
|
17
|
-
this.agent = agent;
|
|
18
|
-
this.packages = ['mongodb'];
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
MongoObserver.prototype.inject = function( mod, moduleName ) {
|
|
22
|
-
if(mod.__whatap_observe__) {return;}
|
|
23
|
-
mod.__whatap_observe__ = true;
|
|
24
|
-
|
|
25
|
-
Logger.initPrint("MongoObserver");
|
|
26
|
-
|
|
27
|
-
var self = this;
|
|
28
|
-
var conn_dbc_hash=0;
|
|
29
|
-
var dbc = '';
|
|
30
|
-
self.agent.aop.both(mod.MongoClient.prototype, ['connect'], function (obj, args, lctx) {
|
|
31
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
32
|
-
if(ctx == null) { return; }
|
|
33
|
-
lctx.context = ctx;
|
|
34
|
-
|
|
35
|
-
if(obj.s && obj.s.url){
|
|
36
|
-
dbc = obj.s.url;
|
|
37
|
-
conn_dbc_hash = HashUtil.hashFromString(dbc);
|
|
38
|
-
DataTextAgent.DBC.add(conn_dbc_hash, dbc);
|
|
39
|
-
DataTextAgent.METHOD.add(conn_dbc_hash, dbc);
|
|
40
|
-
DataTextAgent.ERROR.add(conn_dbc_hash, dbc);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var dbc_step = new DBCStep();
|
|
44
|
-
dbc_step.hash = conn_dbc_hash;
|
|
45
|
-
dbc_step.start_time = ctx.getElapsedTime();
|
|
46
|
-
|
|
47
|
-
lctx.step = dbc_step;
|
|
48
|
-
}, function (obj, args, ret, lctx) {
|
|
49
|
-
var pool = ret;
|
|
50
|
-
var ctx = lctx.context,
|
|
51
|
-
step = lctx.step;
|
|
52
|
-
|
|
53
|
-
if(ctx == null || step == null) { return; }
|
|
54
|
-
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
55
|
-
ctx.profile.push(step);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
var insertCommnad = ['insert', 'insertOne', 'insertMany'];
|
|
59
|
-
insertCommnad.forEach(function (command) {
|
|
60
|
-
self.agent.aop.before(mod.Collection.prototype, command, function (obj, args) {
|
|
61
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
62
|
-
if(ctx == null) { return; }
|
|
63
|
-
if(ctx && ctx.__mongoose_traced__) { return; }
|
|
64
|
-
|
|
65
|
-
ctx.footprint('Mongodb Command Start: ' + command );
|
|
66
|
-
var sql_step;
|
|
67
|
-
try {
|
|
68
|
-
sql_step = new SqlStepX();
|
|
69
|
-
var sql = command ;//+ ': ' + JSON.stringify(Object.keys(args[0]));
|
|
70
|
-
if(args[0]){
|
|
71
|
-
sql += ' field=' + JSON.stringify(Object.keys(args[0]))
|
|
72
|
-
}
|
|
73
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
74
|
-
sql_step.start_time = ctx.getElapsedTime();
|
|
75
|
-
//sql_step.crud = 'I'.charCodeAt(0);
|
|
76
|
-
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
77
|
-
ctx.profile.push(sql_step);
|
|
78
|
-
} catch(e) {
|
|
79
|
-
Logger.printError("WHATAP-605", "Mongodb insert error", e, false);
|
|
80
|
-
sql_step = null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
self.agent.aop.functionHook(args, -1, function (obj, args) {
|
|
84
|
-
if(TraceContextManager.resume(ctx._id) == null || sql_step == null) { return; }
|
|
85
|
-
|
|
86
|
-
ctx.footprint('Mongodb Command Done: ' + command );
|
|
87
|
-
|
|
88
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
var findCommand = ['find'];
|
|
94
|
-
findCommand.forEach(function (command) {
|
|
95
|
-
self.agent.aop.both(mod.Collection.prototype, command, function (obj, args, lctx) {
|
|
96
|
-
var ctx = lctx.context;
|
|
97
|
-
if(ctx == null) { return; }
|
|
98
|
-
if(ctx && ctx.__mongoose_traced__) { return; }
|
|
99
|
-
|
|
100
|
-
ctx.footprint('Mongodb Command Start: ' + command );
|
|
101
|
-
var sql_step;
|
|
102
|
-
try {
|
|
103
|
-
if(dbc){
|
|
104
|
-
sql_step = new SqlStepX();
|
|
105
|
-
var sql = command ;//+ ': ' + JSON.stringify(Object.keys(args[0]));
|
|
106
|
-
if(args[0]){
|
|
107
|
-
sql += ' where=' + JSON.stringify(Object.keys(args[0]))
|
|
108
|
-
}
|
|
109
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
110
|
-
sql_step.start_time = ctx.getElapsedTime();
|
|
111
|
-
//sql_step.crud = 'S'.charCodeAt(0);
|
|
112
|
-
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
113
|
-
ctx.profile.push(sql_step);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
} catch (e) {
|
|
117
|
-
Logger.printError("WHATAP-606", "Mongodb find error", e, false);
|
|
118
|
-
sql_step = null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
self.agent.aop.functionHook(args, -1, function (obj, args, ret) {
|
|
122
|
-
if(TraceContextManager.resume(ctx._id) == null) { return; }
|
|
123
|
-
|
|
124
|
-
ctx.footprint('Mongodb Command Done: ' + command );
|
|
125
|
-
|
|
126
|
-
if(args[0] != null) {
|
|
127
|
-
//error
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if(args[1]) {
|
|
131
|
-
self.agent.aop.before(args[1], 'toArray', function (obj, args) {
|
|
132
|
-
|
|
133
|
-
var result_step = new ResultSetStep();
|
|
134
|
-
result_step.start_time = ctx.getElapsedTime();
|
|
135
|
-
result_step.sqlhash = sql_step.hash;
|
|
136
|
-
ctx.profile.push(result_step);
|
|
137
|
-
|
|
138
|
-
ctx.footprint('Mongodb Fetch Start');
|
|
139
|
-
|
|
140
|
-
self.agent.aop.functionHook(args, -1, null, function (obj, args) {
|
|
141
|
-
if(TraceContextManager.resume(ctx._id) == null) { return; }
|
|
142
|
-
|
|
143
|
-
ctx.footprint('Mongodb Fetch Done');
|
|
144
|
-
|
|
145
|
-
if(args[0]) { return; }
|
|
146
|
-
result_step.elapsed = ctx.getElapsedTime() - result_step.start_time;
|
|
147
|
-
if(Array.isArray(args[1])) {
|
|
148
|
-
result_step.fetch = args[1].length;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
}, function (obj, args, ret, lctx) {
|
|
158
|
-
var ctx = lctx.context;
|
|
159
|
-
if(ctx == null) { return; }
|
|
160
|
-
//Monk
|
|
161
|
-
if(ret) {
|
|
162
|
-
var sql_step = ctx.profile.getLastSteps(1)[0];
|
|
163
|
-
if(sql_step) {
|
|
164
|
-
self.agent.aop.after(ret, 'toArray', function (obj, args) {
|
|
165
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
166
|
-
ctx.footprint('Mongodb Command Done');
|
|
167
|
-
|
|
168
|
-
var result_step = new ResultSetStep();
|
|
169
|
-
result_step.start_time = ctx.getElapsedTime();
|
|
170
|
-
result_step.sqlhash = sql_step.hash;
|
|
171
|
-
ctx.profile.push(result_step);
|
|
172
|
-
ctx.footprint('Mongodb Fetch Start');
|
|
173
|
-
|
|
174
|
-
self.agent.aop.functionHook(args, -1, null, function (obj, args) {
|
|
175
|
-
if(TraceContextManager.resume(ctx._id) == null) { return; }
|
|
176
|
-
|
|
177
|
-
ctx.footprint('Mongodb Fetch Done');
|
|
178
|
-
|
|
179
|
-
if(args[0]) { return; }
|
|
180
|
-
result_step.elapsed = ctx.getElapsedTime() - result_step.start_time;
|
|
181
|
-
if(Array.isArray(args[1])) {
|
|
182
|
-
result_step.fetch = args[1].length;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
var updateCommand = ['update', 'updateOne', 'updateMany'];
|
|
192
|
-
updateCommand.forEach(function (command) {
|
|
193
|
-
self.agent.aop.both(mod.Collection.prototype, command, function (obj, args) {
|
|
194
|
-
//args[0] where, args[1] set
|
|
195
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
196
|
-
if(ctx == null) {return;}
|
|
197
|
-
if(ctx && ctx.__mongoose_traced__) { return; }
|
|
198
|
-
|
|
199
|
-
ctx.footprint('Mongodb Command Start: '+command);
|
|
200
|
-
var sql_step;
|
|
201
|
-
try{
|
|
202
|
-
sql_step = new SqlStepX();
|
|
203
|
-
var sql = command ;//+ ': set=' + JSON.stringify(Object.keys(args[1]))
|
|
204
|
-
if(args[0]){
|
|
205
|
-
sql += ' where=' + JSON.stringify(Object.keys(args[0]))
|
|
206
|
-
}
|
|
207
|
-
if(args[1]){
|
|
208
|
-
if(args[1]['$set']) sql += ', field=' + JSON.stringify(Object.keys(args[1]['$set']));
|
|
209
|
-
else sql += ' field =' + JSON.stringify(Object.keys(args[1]));
|
|
210
|
-
}
|
|
211
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
212
|
-
sql_step.start_time = ctx.getElapsedTime();
|
|
213
|
-
//sql_step.crud = 'U'.charCodeAt(0);
|
|
214
|
-
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
215
|
-
ctx.profile.push(sql_step);
|
|
216
|
-
} catch(e) {
|
|
217
|
-
Logger.printError("WHATAP-607", "Mongodb update error", e, false);
|
|
218
|
-
sql_step = null;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
self.agent.aop.functionHook(args, -1, null, function (obj, args) {
|
|
222
|
-
if(TraceContextManager.resume(ctx._id) == null || sql_step == null) { return; }
|
|
223
|
-
|
|
224
|
-
ctx.footprint('Mongodb Command Done: '+command);
|
|
225
|
-
|
|
226
|
-
if(args[0] != null) {
|
|
227
|
-
//error
|
|
228
|
-
}
|
|
229
|
-
// if(args.length > 1) {
|
|
230
|
-
// var result = args[1];
|
|
231
|
-
// sql_step.updated = result.result['nModified'] || 0;
|
|
232
|
-
// }
|
|
233
|
-
|
|
234
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
var deleteCommand = ['delete', 'deleteMany', 'deleteOne', 'remove', 'removeMany', 'removeOne'];
|
|
240
|
-
deleteCommand.forEach(function (command) {
|
|
241
|
-
self.agent.aop.both(mod.Collection.prototype, command, function (obj, args) {
|
|
242
|
-
//args[0] where
|
|
243
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
244
|
-
if(ctx == null) { return; }
|
|
245
|
-
if(ctx && ctx.__mongoose_traced__) { return; }
|
|
246
|
-
|
|
247
|
-
ctx.footprint('Mongodb Command Start: '+command);
|
|
248
|
-
var sql_step;
|
|
249
|
-
try{
|
|
250
|
-
sql_step = new SqlStepX();
|
|
251
|
-
var sql = command ;//+ ': ' + JSON.stringify(Object.keys(args[0]));
|
|
252
|
-
if(args[0]){
|
|
253
|
-
sql += ', where=' + JSON.stringify(Object.keys(args[0]));
|
|
254
|
-
}
|
|
255
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
256
|
-
sql_step.start_time = ctx.getElapsedTime();
|
|
257
|
-
//sql_step.crud = 'D'.charCodeAt(0);
|
|
258
|
-
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
259
|
-
|
|
260
|
-
ctx.profile.push(sql_step);
|
|
261
|
-
} catch(e) {
|
|
262
|
-
Logger.printError("WHATAP-608", "Mongodb delete error", e, false);
|
|
263
|
-
sql_step = null;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
self.agent.aop.functionHook(args, -1, null, function (obj, args) {
|
|
267
|
-
if(TraceContextManager.resume(ctx._id) == null || sql_step == null) { return; }
|
|
268
|
-
|
|
269
|
-
ctx.footprint('Mongodb Command Done: '+command);
|
|
270
|
-
|
|
271
|
-
if(args[0] != null) {
|
|
272
|
-
//error
|
|
273
|
-
}
|
|
274
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
var anotherCommand = ['findAndReplace', 'findAndUpdate', 'findAndDelete'
|
|
280
|
-
, 'findOneAndUpdate', 'findOneAndReplace', 'findOneAndDelete', 'findAndModify'];
|
|
281
|
-
anotherCommand.forEach(function (command) {
|
|
282
|
-
self.agent.aop.both(mod.Collection.prototype, command, function (obj, args) {
|
|
283
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
284
|
-
if(ctx == null) { return; }
|
|
285
|
-
if(ctx && ctx.__mongoose_traced__) { return; }
|
|
286
|
-
|
|
287
|
-
ctx.footprint('Mongodb Command Start: '+command);
|
|
288
|
-
var sql_step;
|
|
289
|
-
try{
|
|
290
|
-
|
|
291
|
-
sql_step = new SqlStepX();
|
|
292
|
-
var sql = 'mongodb ' + command ;//+ ': where=' + JSON.stringify(Object.keys(args[0]));
|
|
293
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
294
|
-
sql_step.start_time = ctx.getElapsedTime();
|
|
295
|
-
// sql_step.crud = 'S'.charCodeAt(0);
|
|
296
|
-
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
297
|
-
ctx.profile.push(sql_step);
|
|
298
|
-
} catch(e) {
|
|
299
|
-
Logger.printError("WHATAP-609", "Mongodb delete error", e, false);
|
|
300
|
-
sql_step = null;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
self.agent.aop.functionHook(args, -1, null, function (obj, args) {
|
|
304
|
-
if(TraceContextManager.resume(ctx._id) == null || sql_step == null) { return; }
|
|
305
|
-
|
|
306
|
-
ctx.footprint('Mongodb Command Done: '+command);
|
|
307
|
-
|
|
308
|
-
if(args[0] != null) {
|
|
309
|
-
//error
|
|
310
|
-
}
|
|
311
|
-
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
exports.MongoObserver = MongoObserver;
|
|
@@ -1,77 +0,0 @@
|
|
|
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 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');
|
|
12
|
-
|
|
13
|
-
var trace_background_socket_enabled = conf.getProperty('trace_background_socket_enabled', false);
|
|
14
|
-
conf.on('trace_background_socket_enabled', function (newProps) {
|
|
15
|
-
trace_background_socket_enabled = newProps;
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
var NetObserver = function(agent){
|
|
19
|
-
this.agent = agent;
|
|
20
|
-
this.packages = ['net'];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
NetObserver.prototype.inject = function (mod, moduleName) {
|
|
24
|
-
if(mod.__whatap_observe__) { return; }
|
|
25
|
-
mod.__whatap_observe__ = true;
|
|
26
|
-
Logger.initPrint("NetObserver");
|
|
27
|
-
if ( !trace_background_socket_enabled ) { return; }
|
|
28
|
-
|
|
29
|
-
var self = this;
|
|
30
|
-
var aop = self.agent.aop;
|
|
31
|
-
|
|
32
|
-
aop.both(mod.Socket.prototype, ['connect'],
|
|
33
|
-
function (obj, args, lctx) {
|
|
34
|
-
var ctx = lctx.context;
|
|
35
|
-
if(!ctx || !trace_background_socket_enabled){
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
var info, host, port;
|
|
39
|
-
if(args.length > 0){
|
|
40
|
-
info = args[0];
|
|
41
|
-
host = info.host;
|
|
42
|
-
port = info.port;
|
|
43
|
-
}
|
|
44
|
-
if(port == undefined){
|
|
45
|
-
lctx.step = null;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
ctx.socket_connecting=true;
|
|
49
|
-
|
|
50
|
-
ctx.footprint('Socket Connecting: ' + host+':'+port);
|
|
51
|
-
|
|
52
|
-
var step = new SocketStep();
|
|
53
|
-
step.start_time = ctx.getElapsedTime();
|
|
54
|
-
step.ipaddr = Buffer.from(IPUtil.stringToBytes(host));
|
|
55
|
-
step.port = port;
|
|
56
|
-
// obj.on('lookup', function(err, ip, addressType){
|
|
57
|
-
// if(step != null) {
|
|
58
|
-
// step.ipaddr = new Buffer(IPUtil.stringToBytes(ip));
|
|
59
|
-
// }
|
|
60
|
-
// });
|
|
61
|
-
ctx.profile.push(step);
|
|
62
|
-
lctx.step = step;
|
|
63
|
-
},
|
|
64
|
-
function (obj, args, ret, lctx) {
|
|
65
|
-
var ctx = lctx.context;
|
|
66
|
-
var step = lctx.step;
|
|
67
|
-
if(!ctx || !step || !trace_background_socket_enabled){
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
ctx.socket_connecting=false;
|
|
71
|
-
step.elapsed = ctx.getElapsedTime() - step.start_time;
|
|
72
|
-
ctx.footprint('Socket Connecting Done');
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.NetObserver = NetObserver;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by yunhoi on 12/06/2017.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
var TraceContextManager = require('../trace/trace-context-manager'),
|
|
6
|
-
Logger = require('../logger');
|
|
7
|
-
|
|
8
|
-
var PromiseObserver = function (agent) {
|
|
9
|
-
this.agent = agent;
|
|
10
|
-
this.packages = ['promise', 'bluebird'];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
PromiseObserver.prototype.inject = function (mod, moduleName) {
|
|
14
|
-
|
|
15
|
-
var self = this;
|
|
16
|
-
var aop = self.agent.aop;
|
|
17
|
-
|
|
18
|
-
if(mod.__whatap_observe__) {return;}
|
|
19
|
-
mod.__whatap_observe__ = true;
|
|
20
|
-
Logger.initPrint("PromiseObserver");
|
|
21
|
-
aop.both(mod.prototype, 'then'
|
|
22
|
-
, function (obj, args, lctx) {
|
|
23
|
-
var ctx = TraceContextManager.getCurrentContext();
|
|
24
|
-
aop.functionHook(args, -1, function (obj, args) {
|
|
25
|
-
TraceContextManager.resume(ctx);
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.PromiseObserver = PromiseObserver;
|
|
@@ -1,67 +0,0 @@
|
|
|
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 TraceContextManager = require('../trace/trace-context-manager'),
|
|
8
|
-
conf = require('../conf/configure'),
|
|
9
|
-
DataTextAgent = require('../data/datatext-agent'),
|
|
10
|
-
DataProfileAgent = require('../data/dataprofile-agent'),
|
|
11
|
-
EventLevel = require('../data/event-level'),
|
|
12
|
-
TxRecord = require('../service/tx-record'),
|
|
13
|
-
ProfilePack = require('../pack/profile-pack'),
|
|
14
|
-
SecurityMaster = require('../net/security-master'),
|
|
15
|
-
HashUtil = require('../util/hashutil'),
|
|
16
|
-
DateUtil = require('../util/dateutil'),
|
|
17
|
-
ResourceProfile = require('../util/resourceprofile'),
|
|
18
|
-
MessageStep = require('../step/message-step'),
|
|
19
|
-
Logger = require('../logger');
|
|
20
|
-
|
|
21
|
-
var ScheduleObserver = function(agent){
|
|
22
|
-
this.agent = agent;
|
|
23
|
-
this.packages = ['node-schedule'];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
ScheduleObserver.prototype.inject = function (mod, moduleName) {
|
|
27
|
-
if(mod.__whatap_observe__) { return; }
|
|
28
|
-
mod.__whatap_observe__ = true;
|
|
29
|
-
Logger.initPrint("ScheduleObserver");
|
|
30
|
-
var self = this;
|
|
31
|
-
var aop = self.agent.aop;
|
|
32
|
-
|
|
33
|
-
aop.after(mod, 'scheduleJob',
|
|
34
|
-
function (obj, args, ret) {
|
|
35
|
-
var orig = ret.job;
|
|
36
|
-
if(!orig) return;
|
|
37
|
-
ret.job = async () => {
|
|
38
|
-
var ctx = null;
|
|
39
|
-
if(conf['trace_node_schedule_enabled']) {
|
|
40
|
-
ctx = TraceContextManager.startTrace('ScheduleJob');
|
|
41
|
-
}
|
|
42
|
-
var result = null;
|
|
43
|
-
try {
|
|
44
|
-
result = await orig.apply(this, arguments);
|
|
45
|
-
} catch(err) {
|
|
46
|
-
Logger.printError('WHATAP-607', 'End batch error..', err, false);
|
|
47
|
-
}
|
|
48
|
-
if(conf['trace_node_schedule_enabled'] && ctx != null) {
|
|
49
|
-
try {
|
|
50
|
-
var step = new MessageStep();
|
|
51
|
-
step.msg = 'Node ScheduleJob finished!!!!!'
|
|
52
|
-
step.hash = HashUtil.hashFromString(step.msg);;
|
|
53
|
-
step.start_time = ctx.getElapsedTime();
|
|
54
|
-
step.desc = '';
|
|
55
|
-
DataTextAgent.MESSAGE.add(step.hash, step.msg);
|
|
56
|
-
ctx.profile.add(step);
|
|
57
|
-
TraceContextManager.endTrace(ctx);
|
|
58
|
-
if(ctx != null) ctx = null;
|
|
59
|
-
} catch(err) {}
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
exports.ScheduleObserver = ScheduleObserver;
|
|
@@ -1,19 +0,0 @@
|
|
|
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 StreamObserver = function(agent) {
|
|
9
|
-
this.agent = agent;
|
|
10
|
-
this.aop = agent.aop;
|
|
11
|
-
this.packages = ['stream'];
|
|
12
|
-
};
|
|
13
|
-
StreamObserver.prototype.inject = function (mod, moduleName) {
|
|
14
|
-
if(mod.__whatap_observe__) { return; }
|
|
15
|
-
mod.__whatap_observe__ = true;
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.StreamObserver = StreamObserver;
|