whatap 0.5.26 → 1.0.0-canary.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/README.md +78 -32
- 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/whatap.conf +4 -1
- 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,336 +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
|
-
Logger = require('../logger');
|
|
10
|
-
const { Detector: URLPatternDetector } = require("../trace/serviceurl-pattern-detector");
|
|
11
|
-
const HashUtil = require("../util/hashutil");
|
|
12
|
-
const DataTextAgent = require("../data/datatext-agent");
|
|
13
|
-
const ResourceProfile = require("../util/resourceprofile");
|
|
14
|
-
const ProfilePack = require('../pack/profile-pack');
|
|
15
|
-
const TxRecord = require('../service/tx-record');
|
|
16
|
-
const DateUtil = require('../util/dateutil');
|
|
17
|
-
const SecurityMaster = require('../net/security-master');
|
|
18
|
-
const DataProfileAgent = require("../data/dataprofile-agent");
|
|
19
|
-
const MessageStep = require("../step/message-step");
|
|
20
|
-
const MeterService = require('../counter/meter/meter-service').MeterService;
|
|
21
|
-
|
|
22
|
-
const shimmer = require('../core/shimmer');
|
|
23
|
-
const StatError = require("../stat/stat-error");
|
|
24
|
-
|
|
25
|
-
var grpc_profile_enabled = conf.getProperty('grpc_profile_enabled', true);
|
|
26
|
-
var grpc_profile_stream_client_enabled = conf.getProperty('grpc_profile_stream_client_enabled', true);
|
|
27
|
-
var grpc_profile_stream_server_enabled = conf.getProperty('grpc_profile_stream_server_enabled', true);
|
|
28
|
-
var grpc_profile_ignore_method = conf.getProperty('grpc_profile_ignore_method', '');
|
|
29
|
-
var ignore_method_set = null;
|
|
30
|
-
conf.on('grpc_profile_enabled', function(newProperty) {
|
|
31
|
-
grpc_profile_enabled = newProperty;
|
|
32
|
-
});
|
|
33
|
-
conf.on('grpc_profile_stream_client_enabled', function(newProperty) {
|
|
34
|
-
grpc_profile_stream_client_enabled = newProperty;
|
|
35
|
-
});
|
|
36
|
-
conf.on('grpc_profile_stream_server_enabled', function(newProperty) {
|
|
37
|
-
grpc_profile_stream_server_enabled = newProperty;
|
|
38
|
-
});
|
|
39
|
-
conf.on('grpc_profile_ignore_method', function(newProperty) {
|
|
40
|
-
grpc_profile_ignore_method = newProperty;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var GRpcObserver = function(agent) {
|
|
44
|
-
this.agent = agent;
|
|
45
|
-
this.packages = ['@grpc/grpc-js'];
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const types = {
|
|
49
|
-
unary: 'unary',
|
|
50
|
-
client_stream: 'clientStream',
|
|
51
|
-
server_stream: 'serverStream',
|
|
52
|
-
bidi: 'bidi'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
GRpcObserver.prototype.inject = function(mod, moduleName) {
|
|
56
|
-
if (mod.__whatap_observe__) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
mod.__whatap_observe__ = true;
|
|
60
|
-
Logger.initPrint("GRpcObserver");
|
|
61
|
-
|
|
62
|
-
if (grpc_profile_enabled) {
|
|
63
|
-
shimmer.wrap(mod.Server.prototype, 'register', wrapRegister);
|
|
64
|
-
shimmer.wrap(mod.Client.prototype, 'register', wrapRegister);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
function checkIgnoreMethod(ignore_method, method_name){
|
|
69
|
-
try{
|
|
70
|
-
if (ignore_method) {
|
|
71
|
-
ignore_method_set = new Set(ignore_method.split(','));
|
|
72
|
-
} else {
|
|
73
|
-
ignore_method_set = null;
|
|
74
|
-
}
|
|
75
|
-
if (ignore_method_set && ignore_method_set.has(method_name)) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}catch (e) {
|
|
79
|
-
Logger.printError('WHATAP-703', 'gRPC checkIgnoreMethod error: ' + e, false);
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function wrapHandler(handler, methodName, type) {
|
|
85
|
-
return function(call, callback) {
|
|
86
|
-
var method_name = methodName.includes('/') ? methodName.substring(methodName.lastIndexOf('/')+1, methodName.length) : methodName
|
|
87
|
-
if (!grpc_profile_enabled || checkIgnoreMethod(conf.getProperty('grpc_profile_ignore_method', ''), method_name)) {
|
|
88
|
-
return handler.call(this, call, callback);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
TraceContextManager._asyncLocalStorage.run(initCtx(), () => {
|
|
92
|
-
var ctx = TraceContextManager._asyncLocalStorage.getStore();
|
|
93
|
-
try {
|
|
94
|
-
if (!ctx) {
|
|
95
|
-
return handler.call(this, call, callback);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
ctx.service_name = methodName;
|
|
99
|
-
ctx.service_hash = HashUtil.hashFromString(methodName);
|
|
100
|
-
|
|
101
|
-
var step_type = new MessageStep();
|
|
102
|
-
step_type.hash = HashUtil.hashFromString('Type');
|
|
103
|
-
step_type.start_time = ctx.getElapsedTime();
|
|
104
|
-
step_type.desc = type;
|
|
105
|
-
DataTextAgent.MESSAGE.add(step_type.hash, "Type");
|
|
106
|
-
ctx.profile.push(step_type);
|
|
107
|
-
|
|
108
|
-
var step_method = new MessageStep();
|
|
109
|
-
step_method.hash = HashUtil.hashFromString('Method');
|
|
110
|
-
step_method.start_time = ctx.getElapsedTime();
|
|
111
|
-
step_method.desc = method_name;
|
|
112
|
-
DataTextAgent.MESSAGE.add(step_method.hash, "Method");
|
|
113
|
-
ctx.profile.push(step_method);
|
|
114
|
-
|
|
115
|
-
if(call.request && Object.keys(call.request).length > 0){
|
|
116
|
-
var step_param = new MessageStep();
|
|
117
|
-
step_param.hash = HashUtil.hashFromString('Parameter');
|
|
118
|
-
step_param.start_time = ctx.getElapsedTime();
|
|
119
|
-
step_param.desc = JSON.stringify(Object.keys(call.request));
|
|
120
|
-
DataTextAgent.MESSAGE.add(step_param.hash, "Parameter");
|
|
121
|
-
ctx.profile.push(step_param);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
ctx.grpc_method = method_name;
|
|
125
|
-
|
|
126
|
-
function wrappedCallback(err, response, ctx) {
|
|
127
|
-
|
|
128
|
-
if (err) {
|
|
129
|
-
ctx.error = err.stack;
|
|
130
|
-
ctx.statusCode = 500;
|
|
131
|
-
ctx.error_message = err.message;
|
|
132
|
-
ctx.error_class = err.name || err.constructor?.name || 'GrpcError';
|
|
133
|
-
|
|
134
|
-
var step_error = new MessageStep();
|
|
135
|
-
step_error.hash = HashUtil.hashFromString("EXCEPTION");
|
|
136
|
-
step_error.start_time = ctx.getElapsedTime();
|
|
137
|
-
step_error.desc = err.stack;
|
|
138
|
-
DataTextAgent.MESSAGE.add(step_error.hash, "EXCEPTION");
|
|
139
|
-
ctx.profile.push(step_error);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
endTransaction(ctx);
|
|
143
|
-
|
|
144
|
-
if (typeof callback === 'function') {
|
|
145
|
-
return callback(err, response);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return handler.call(this, call, (err, response) => wrappedCallback(err, response, ctx));
|
|
150
|
-
} catch (err) {
|
|
151
|
-
Logger.printError('WHATAP-701', 'gRPC wrapHandler error: ' + err, false);
|
|
152
|
-
|
|
153
|
-
if(ctx.error.isZero()) {
|
|
154
|
-
ctx.error = StatError.addError(err.code, err.message, ctx.service_hash);
|
|
155
|
-
}
|
|
156
|
-
ctx.error_message = err.message;
|
|
157
|
-
ctx.error_class = err.name || err.constructor?.name || 'GrpcError';
|
|
158
|
-
|
|
159
|
-
var step_error = new MessageStep();
|
|
160
|
-
step_error.hash = HashUtil.hashFromString("EXCEPTION");
|
|
161
|
-
step_error.start_time = ctx.getElapsedTime();
|
|
162
|
-
step_error.desc = err.stack;
|
|
163
|
-
DataTextAgent.MESSAGE.add(step_error.hash, "EXCEPTION");
|
|
164
|
-
ctx.profile.push(step_error);
|
|
165
|
-
|
|
166
|
-
endTransaction(ctx);
|
|
167
|
-
|
|
168
|
-
return handler.call(this, call, callback);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function wrapStreamHandler(handler, methodName, type) {
|
|
175
|
-
return function(call, callback) {
|
|
176
|
-
var method_name = methodName.includes('/') ? methodName.substring(methodName.lastIndexOf('/')+1, methodName.length) : methodName
|
|
177
|
-
if (!grpc_profile_enabled || checkIgnoreMethod(conf.getProperty('grpc_profile_ignore_method', ''), method_name)) {
|
|
178
|
-
return handler.call(this, call, callback);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
switch (type) {
|
|
182
|
-
case 'server_stream':
|
|
183
|
-
if (!grpc_profile_stream_server_enabled) {
|
|
184
|
-
return handler.call(this, call, callback);
|
|
185
|
-
}
|
|
186
|
-
break;
|
|
187
|
-
case 'client_stream':
|
|
188
|
-
if (!grpc_profile_stream_client_enabled) {
|
|
189
|
-
return handler.call(this, call, callback);
|
|
190
|
-
}
|
|
191
|
-
break;
|
|
192
|
-
case 'bidi':
|
|
193
|
-
if (!grpc_profile_stream_server_enabled || !grpc_profile_stream_client_enabled) {
|
|
194
|
-
return handler.call(this, call, callback);
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
TraceContextManager._asyncLocalStorage.run(initCtx(), () => {
|
|
200
|
-
try {
|
|
201
|
-
var ctx = TraceContextManager._asyncLocalStorage.getStore();
|
|
202
|
-
if (!ctx) {
|
|
203
|
-
return handler.call(this, call, callback);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
ctx.service_name = methodName;
|
|
207
|
-
ctx.service_hash = HashUtil.hashFromString(methodName);
|
|
208
|
-
|
|
209
|
-
var step_type = new MessageStep();
|
|
210
|
-
step_type.hash = HashUtil.hashFromString('Type');
|
|
211
|
-
step_type.start_time = ctx.getElapsedTime();
|
|
212
|
-
step_type.desc = type;
|
|
213
|
-
DataTextAgent.MESSAGE.add(step_type.hash, "Type");
|
|
214
|
-
ctx.profile.push(step_type);
|
|
215
|
-
|
|
216
|
-
var step_method = new MessageStep();
|
|
217
|
-
step_method.hash = HashUtil.hashFromString('Method');
|
|
218
|
-
step_method.start_time = ctx.getElapsedTime();
|
|
219
|
-
step_method.desc = method_name;
|
|
220
|
-
DataTextAgent.MESSAGE.add(step_method.hash, "Method");
|
|
221
|
-
ctx.profile.push(step_method);
|
|
222
|
-
|
|
223
|
-
ctx.grpc_method = method_name;
|
|
224
|
-
|
|
225
|
-
const startTime = Date.now();
|
|
226
|
-
|
|
227
|
-
call.on('end', () => {
|
|
228
|
-
const duration = Date.now() - startTime;
|
|
229
|
-
endTransaction(ctx);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
call.once('cancelled', () => {
|
|
233
|
-
ctx.cancelled = true;
|
|
234
|
-
var step_cancel = new MessageStep();
|
|
235
|
-
step_cancel.hash = HashUtil.hashFromString("CANCELLED");
|
|
236
|
-
step_cancel.start_time = ctx.getElapsedTime();
|
|
237
|
-
step_cancel.desc = "Request cancelled";
|
|
238
|
-
DataTextAgent.MESSAGE.add(step_cancel.hash, "CANCELLED");
|
|
239
|
-
ctx.profile.push(step_cancel);
|
|
240
|
-
endTransaction(ctx);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
call.on('error', (err) => {
|
|
244
|
-
ctx.error = err.stack;
|
|
245
|
-
ctx.statusCode = err.code || grpc.status.INTERNAL;
|
|
246
|
-
|
|
247
|
-
var step_error = new MessageStep();
|
|
248
|
-
step_error.hash = HashUtil.hashFromString("EXCEPTION");
|
|
249
|
-
step_error.start_time = ctx.getElapsedTime();
|
|
250
|
-
step_error.desc = err.stack;
|
|
251
|
-
DataTextAgent.MESSAGE.add(step_error.hash, "EXCEPTION");
|
|
252
|
-
ctx.profile.push(step_error);
|
|
253
|
-
|
|
254
|
-
endTransaction(ctx);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
return handler.call(this, call);
|
|
258
|
-
} catch (e) {
|
|
259
|
-
Logger.printError('WHATAP-702', 'gRPC wrapStreamHandler error: ' + e, false);
|
|
260
|
-
return handler.call(this, call);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function wrapRegister(register) {
|
|
267
|
-
return function(name, handler, serialize, deserialize, type) {
|
|
268
|
-
if (typeof handler === 'function') {
|
|
269
|
-
switch (type) {
|
|
270
|
-
case types.client_stream:
|
|
271
|
-
handler = wrapStreamHandler(handler, name, 'clientStream');
|
|
272
|
-
break;
|
|
273
|
-
case types.server_stream:
|
|
274
|
-
handler = wrapStreamHandler(handler, name, 'serverStream');
|
|
275
|
-
break;
|
|
276
|
-
case types.bidi:
|
|
277
|
-
handler = wrapStreamHandler(handler, name, 'bidi');
|
|
278
|
-
break;
|
|
279
|
-
case types.unary:
|
|
280
|
-
default:
|
|
281
|
-
handler = wrapHandler(handler, name, 'unary');
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return register.call(this, name, handler, serialize, deserialize, type);
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function endTransaction(ctx) {
|
|
289
|
-
try {
|
|
290
|
-
var profile = new ProfilePack();
|
|
291
|
-
var wtx = new TxRecord();
|
|
292
|
-
wtx.endTime = DateUtil.currentTime();
|
|
293
|
-
profile.time = wtx.endTime;
|
|
294
|
-
wtx.elapsed = ctx.getElapsedTime();
|
|
295
|
-
|
|
296
|
-
DataTextAgent.SERVICE.add(ctx.service_hash, ctx.service_name);
|
|
297
|
-
|
|
298
|
-
wtx.seq = ctx.txid;
|
|
299
|
-
wtx.service = ctx.service_hash;
|
|
300
|
-
wtx.cpuTime = ResourceProfile.getCPUTime() - ctx.start_cpu;
|
|
301
|
-
wtx.malloc = ResourceProfile.getUsedHeapSize() - ctx.start_malloc;
|
|
302
|
-
if (wtx.malloc < 0) { wtx.malloc = 0; }
|
|
303
|
-
wtx.status = 2;
|
|
304
|
-
wtx.http_method = ctx.grpc_method;
|
|
305
|
-
|
|
306
|
-
wtx.ipaddr = ctx.remoteIp;
|
|
307
|
-
|
|
308
|
-
MeterService.add(wtx.service, wtx.elapsed,
|
|
309
|
-
wtx.errorLevel, ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
|
|
310
|
-
|
|
311
|
-
profile.oid = SecurityMaster.OID;
|
|
312
|
-
profile.service = wtx;
|
|
313
|
-
|
|
314
|
-
TraceContextManager.end(ctx._id);
|
|
315
|
-
|
|
316
|
-
setTimeout(function() {
|
|
317
|
-
DataProfileAgent.sendProfile(ctx, profile, false);
|
|
318
|
-
ctx = null;
|
|
319
|
-
}, 100);
|
|
320
|
-
} catch (e) {
|
|
321
|
-
Logger.printError('WHATAP-615', 'Websocket end transaction error..', e, false);
|
|
322
|
-
TraceContextManager.end(ctx._id);
|
|
323
|
-
ctx = null;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
function initCtx() {
|
|
328
|
-
const ctx = TraceContextManager.start();
|
|
329
|
-
if (!ctx) { return; }
|
|
330
|
-
|
|
331
|
-
ctx.start_malloc = ResourceProfile.getUsedHeapSize();
|
|
332
|
-
ctx.start_cpu = ResourceProfile.getCPUTime();
|
|
333
|
-
return ctx;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
exports.GRpcObserver = GRpcObserver;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var TraceContextManager = require('../trace/trace-context-manager'),
|
|
3
|
-
SqlStepX = require('../step/sql-stepx'),
|
|
4
|
-
DBCStep = require('../step/dbc-step'),
|
|
5
|
-
DataTextAgent = require('../data/datatext-agent'),
|
|
6
|
-
HashUtil = require('../util/hashutil');
|
|
7
|
-
|
|
8
|
-
var MemcachedObserver = function (agent) {
|
|
9
|
-
this.agent = agent;
|
|
10
|
-
this.aop = agent.aop;
|
|
11
|
-
this.packages = ['memcached'];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var commands = [
|
|
15
|
-
'get',
|
|
16
|
-
'gets',
|
|
17
|
-
'getMulti',
|
|
18
|
-
'set',
|
|
19
|
-
'replace',
|
|
20
|
-
'add',
|
|
21
|
-
'cas',
|
|
22
|
-
'append',
|
|
23
|
-
'prepend',
|
|
24
|
-
'increment',
|
|
25
|
-
'decrement',
|
|
26
|
-
'incr',
|
|
27
|
-
'decr',
|
|
28
|
-
'del',
|
|
29
|
-
'delete',
|
|
30
|
-
'version',
|
|
31
|
-
'flush',
|
|
32
|
-
'samples',
|
|
33
|
-
'slabs',
|
|
34
|
-
'items',
|
|
35
|
-
'flushAll',
|
|
36
|
-
'statsSettings',
|
|
37
|
-
'statsSlabs',
|
|
38
|
-
'statsItems',
|
|
39
|
-
'cachedump'
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
MemcachedObserver.prototype.inject = function (mod, modName) {
|
|
43
|
-
|
|
44
|
-
var self = this;
|
|
45
|
-
if(mod.__whatap_observe__) {return;}
|
|
46
|
-
mod.__whatap_observe__ = true;
|
|
47
|
-
|
|
48
|
-
commands.forEach(function (command) {
|
|
49
|
-
self.aop.before(mod.prototype, command, function (obj, args) {
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
exports.MemcachedObserver = MemcachedObserver;
|