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,162 +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 DataPackSender = require('./datapack-sender'),
|
|
8
|
-
StatTranX = require('../stat/stat-tranx'),
|
|
9
|
-
StatRemoteIp = require('../stat/stat-remote-ip'),
|
|
10
|
-
StatUserAgent = require('../stat/stat-useragent'),
|
|
11
|
-
StatTranxDomain = require('../stat/stat-tx-domain'),
|
|
12
|
-
StatTranxMtCaller = require('../stat/stat-tx-caller'),
|
|
13
|
-
StatTranxReferer = require('../stat/stat-tx-referer'),
|
|
14
|
-
StatRemoteIpUrl = require('../stat/stat-remote-ipurl'),
|
|
15
|
-
conf = require('../conf/configure'),
|
|
16
|
-
HashUtil = require('../util/hashutil'),
|
|
17
|
-
EventLevel = require('../data/event-level'),
|
|
18
|
-
DataTextAgent = require('../data/datatext-agent'),
|
|
19
|
-
Long = require('long'),
|
|
20
|
-
Logger = require('../logger');
|
|
21
|
-
|
|
22
|
-
var ZipProfile = require('./zipprofile');
|
|
23
|
-
var profile_zip_enabled = conf.getProperty('profile_zip_enabled', false);
|
|
24
|
-
var stat_ipurl_enabled = conf.getProperty('stat_ipurl_enabled', false);
|
|
25
|
-
conf.on('profile_zip_enabled', function(newProperty) {
|
|
26
|
-
profile_zip_enabled = newProperty;
|
|
27
|
-
});
|
|
28
|
-
conf.on('stat_ipurl_enabled', function(newProperty) {
|
|
29
|
-
stat_ipurl_enabled = newProperty;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
var DataProfileAgent = {
|
|
33
|
-
last_reject : 0,
|
|
34
|
-
sendProfile : function (ctx, profile, rejected) {
|
|
35
|
-
try {
|
|
36
|
-
StatRemoteIp.incRemoteIp(ctx.remoteIp);
|
|
37
|
-
StatUserAgent.incUserAgent(ctx.userAgent);
|
|
38
|
-
|
|
39
|
-
var transaction = profile.service;
|
|
40
|
-
if(stat_ipurl_enabled && ctx.remoteIp){
|
|
41
|
-
var tc = StatRemoteIpUrl.getService(ctx.remoteIp, ctx.service_hash);
|
|
42
|
-
if (tc) {
|
|
43
|
-
tc.count++;
|
|
44
|
-
if (tc.errorLevel >= EventLevel.WARNING) {
|
|
45
|
-
tc.error++;
|
|
46
|
-
}
|
|
47
|
-
tc.time += transaction.elapsed;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if(conf.stat_domain_enabled && ctx.http_host_hash!=0) {
|
|
52
|
-
StatTranxDomain.add(ctx.http_host_hash, ctx.service_hash, transaction.elapsed, ctx.error != 0);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if(conf.trace_referer_enabled && ctx.referer!=0) {
|
|
56
|
-
StatTranxReferer.add(ctx.referer, ctx.service_hash, transaction.elapsed, ctx.error != 0);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if(conf.stat_mtrace_enabled && ctx.mcaller_pcode!=0) {
|
|
60
|
-
var key = StatTranxMtCaller.getService(ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_spec, ctx.mcaller_url,ctx.service_hash);
|
|
61
|
-
transaction.mthis_spec = conf.mtrace_spec_hash
|
|
62
|
-
|
|
63
|
-
if (ctx.mcaller_spec && ctx.mcaller_spec!='') {
|
|
64
|
-
transaction.mcaller_spec = key.mcaller_spec = HashUtil.hashFromString(ctx.mcaller_spec);
|
|
65
|
-
DataTextAgent.MTRACE_SPEC.add(transaction.mcaller_spec, ctx.mcaller_spec);
|
|
66
|
-
}
|
|
67
|
-
if (ctx.mcaller_url && ctx.mcaller_url!='') {
|
|
68
|
-
transaction.mcaller_url = key.mcaller_url = HashUtil.hashFromString(ctx.mcaller_url);
|
|
69
|
-
DataTextAgent.MTRACE_CALLER_URL.add(transaction.mcaller_url, ctx.mcaller_url);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// additional multi transaction
|
|
73
|
-
//key.url = ctx.service_hash;
|
|
74
|
-
var tc = StatTranxMtCaller.getService(key);
|
|
75
|
-
if (tc != null) {
|
|
76
|
-
tc.count++;
|
|
77
|
-
if (transaction.errorLevel >= EventLevel.WARNING) {
|
|
78
|
-
tc.error++;
|
|
79
|
-
}
|
|
80
|
-
tc.time += transaction.elapsed;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// StatTranxMtCaller.add(ctx.mcaller_pcode,
|
|
84
|
-
// ctx.mcaller_okind,
|
|
85
|
-
// transaction.mcaller_spec,
|
|
86
|
-
// transaction.mcaller_url,
|
|
87
|
-
// ctx.service_hash,
|
|
88
|
-
// transaction.elapsed,
|
|
89
|
-
// ctx.error != 0);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var stat = StatTranX.getService(transaction.service);
|
|
93
|
-
|
|
94
|
-
if(stat !== null) {
|
|
95
|
-
stat.count++;
|
|
96
|
-
if(transaction.error.isZero() ==false) {
|
|
97
|
-
stat.error++;
|
|
98
|
-
}
|
|
99
|
-
if(transaction.elapsed < 0) {
|
|
100
|
-
transaction.elapsed = 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
stat.actived += ctx.profileActive;
|
|
104
|
-
stat.time_sum += transaction.elapsed;
|
|
105
|
-
if (transaction.elapsed > stat.time_max) {
|
|
106
|
-
stat.time_max = transaction.elapsed;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
switch (transaction.apdex) {
|
|
110
|
-
case 2:
|
|
111
|
-
stat.apdex_satisfied++;
|
|
112
|
-
break;
|
|
113
|
-
case 1:
|
|
114
|
-
stat.apdex_tolerated++;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (stat.time_min==0 || transaction.elapsed < stat.time_min) {
|
|
118
|
-
stat.time_min = transaction.elapsed;
|
|
119
|
-
}
|
|
120
|
-
stat.time_std += (Long.fromInt(transaction.elapsed) * Long.fromInt(transaction.elapsed));
|
|
121
|
-
|
|
122
|
-
stat.sql_count += transaction.sqlCount;
|
|
123
|
-
stat.sql_time +=transaction.sqlTime;
|
|
124
|
-
stat.sql_fetch += ctx.rs_count;
|
|
125
|
-
stat.sql_fetch_time +=ctx.rs_time;
|
|
126
|
-
|
|
127
|
-
stat.httpc_count += transaction.httpcCount;
|
|
128
|
-
stat.httpc_time +=transaction.httpcTime;
|
|
129
|
-
|
|
130
|
-
stat.malloc_sum +=transaction.malloc;
|
|
131
|
-
stat.cpu_sum +=transaction.cpuTime;
|
|
132
|
-
|
|
133
|
-
if (rejected) {
|
|
134
|
-
var now = Date.now();
|
|
135
|
-
if (now < this.last_reject + 1000) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
this.last_reject = now;
|
|
139
|
-
} else if (stat.profiled == true // 이전(5분구간 내)에 프로파일이 수집된점이 있음
|
|
140
|
-
&& ctx.profileActive == 0 // 액티브 스택을 추적한적이 없음
|
|
141
|
-
&& transaction.elapsed < conf.profile_basetime
|
|
142
|
-
&& transaction.error.isZero()) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
stat.profiled = true;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
var steps = ctx.profile.getSteps();
|
|
149
|
-
profile.setProfile(steps);
|
|
150
|
-
if(profile_zip_enabled){
|
|
151
|
-
ZipProfile.getInstance().add(profile);
|
|
152
|
-
} else {
|
|
153
|
-
DataPackSender.sendProfilePack(profile);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
} catch(e) {
|
|
157
|
-
Logger.printError('WHATAP-199', 'dataprofile-agent error', e);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
module.exports = DataProfileAgent;
|
|
@@ -1,135 +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
|
-
var RequestQueue = require('../util/request-queue'),
|
|
7
|
-
TextPack = require('../pack/text-pack').TextPack,
|
|
8
|
-
TextRec = require('../pack/text-pack').TextRec,
|
|
9
|
-
TextTypes = require('../lang/text-types'),
|
|
10
|
-
DataPackSender = require('../data/datapack-sender'),
|
|
11
|
-
DateUtil = require('../util/dateutil'),
|
|
12
|
-
IntSet = require('../util/intset');
|
|
13
|
-
|
|
14
|
-
const BUFFERD_MAX = 10 * 1024;
|
|
15
|
-
const INTERVAL = 500; // 제어 가능해야 한다.
|
|
16
|
-
|
|
17
|
-
const DBC = new HashedData(TextTypes.DB_URL, 1000);
|
|
18
|
-
const METHOD = new HashedData(TextTypes.METHOD, 5000);
|
|
19
|
-
const HTTPC_URL = new HashedData(TextTypes.HTTPC_URL, 2000);
|
|
20
|
-
const HTTPC_HOST = new HashedData(TextTypes.HTTPC_HOST, 2000);
|
|
21
|
-
const ERROR = new HashedData(TextTypes.ERROR, 1000);
|
|
22
|
-
const SERVICE = new HashedData(TextTypes.SERVICE, 2000);
|
|
23
|
-
const SQL = new HashedData(TextTypes.SQL, 2000);
|
|
24
|
-
const STACK = new HashedData(TextTypes.STACK_ELEMENTS, 20000);
|
|
25
|
-
const MESSAGE = new HashedData(TextTypes.MESSAGE, 2000);
|
|
26
|
-
const USERAGENT = new HashedData(TextTypes.USER_AGENT, 1000);
|
|
27
|
-
const USER_AGENT_OS = new HashedData(TextTypes.USER_AGENT_OS, 1000);
|
|
28
|
-
const USER_AGENT_BROWSER= new HashedData(TextTypes.USER_AGENT_BROWSER, 1000);
|
|
29
|
-
const REFERER = new HashedData(TextTypes.REFERER, 1000);
|
|
30
|
-
const HTTP_DOMAIN = new HashedData(TextTypes.HTTP_DOMAIN, 500);
|
|
31
|
-
const MTRACE_SPEC = new HashedData(TextTypes.MTRACE_SPEC, 500);
|
|
32
|
-
const MTRACE_CALLER_URL = new HashedData(TextTypes.MTRACE_CALLER_URL, 500);
|
|
33
|
-
const OKIND = new HashedData(TextTypes.OKIND_NAME, 100);
|
|
34
|
-
const ONODE = new HashedData(TextTypes.ONODE_NAME, 100);
|
|
35
|
-
|
|
36
|
-
var DataTextAgent = function () {
|
|
37
|
-
|
|
38
|
-
if(typeof DataTextAgent.instance == 'object') {
|
|
39
|
-
return DataTextAgent.instance;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
this.date = DateUtil.yyyymmddhh();
|
|
43
|
-
this.queue = new RequestQueue(500);
|
|
44
|
-
this.bufferPack = new TextPack();
|
|
45
|
-
this.bufferedLength = 0;
|
|
46
|
-
this.run();
|
|
47
|
-
|
|
48
|
-
DataTextAgent.instance = this;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
DataTextAgent.prototype.run = function () {
|
|
52
|
-
var r = this.queue.get();
|
|
53
|
-
if(r !== null) {
|
|
54
|
-
this.bufferPack.records.push(r);
|
|
55
|
-
this.bufferedLength += r.text.length;
|
|
56
|
-
if(this.bufferedLength >= BUFFERD_MAX) {
|
|
57
|
-
this.send();
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
if(this.bufferedLength > 0) {
|
|
61
|
-
this.send();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if(this.date !== DateUtil.yyyymmddhh()) {
|
|
66
|
-
this.reset();
|
|
67
|
-
this.date = DateUtil.yyyymmddhh();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var self = this;
|
|
71
|
-
setTimeout(function () {
|
|
72
|
-
self.run();
|
|
73
|
-
}, INTERVAL, 'whatap');
|
|
74
|
-
};
|
|
75
|
-
DataTextAgent.prototype.add = function (type, hash, text) {
|
|
76
|
-
this.queue.put(new TextRec(type, hash, text));
|
|
77
|
-
};
|
|
78
|
-
DataTextAgent.prototype.send = function () {
|
|
79
|
-
DataPackSender.sendTextPack(this.bufferPack);
|
|
80
|
-
this.bufferPack = new TextPack();
|
|
81
|
-
this.bufferedLength = 0;
|
|
82
|
-
};
|
|
83
|
-
DataTextAgent.prototype.reset = function () {
|
|
84
|
-
DBC.sent.clear();
|
|
85
|
-
METHOD.sent.clear();
|
|
86
|
-
HTTPC_URL.sent.clear();
|
|
87
|
-
HTTPC_HOST.sent.clear();
|
|
88
|
-
ERROR.sent.clear();
|
|
89
|
-
SERVICE.sent.clear();
|
|
90
|
-
SQL.sent.clear();
|
|
91
|
-
STACK.sent.clear();
|
|
92
|
-
MESSAGE.sent.clear();
|
|
93
|
-
USERAGENT.sent.clear();
|
|
94
|
-
USER_AGENT_OS.sent.clear();
|
|
95
|
-
USER_AGENT_BROWSER.sent.clear();
|
|
96
|
-
REFERER.sent.clear();
|
|
97
|
-
HTTP_DOMAIN.sent.clear();
|
|
98
|
-
MTRACE_SPEC.sent.clear();
|
|
99
|
-
MTRACE_CALLER_URL.sent.clear();
|
|
100
|
-
OKIND.sent.clear();
|
|
101
|
-
ONODE.sent.clear();
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
function HashedData(type, n) {
|
|
105
|
-
this.type = type || 0;
|
|
106
|
-
this.sent = new IntSet().setMax(n);
|
|
107
|
-
}
|
|
108
|
-
HashedData.prototype.add = function (hash, text) {
|
|
109
|
-
if(require('../trace/trace-context-manager').initialized === false) { return; }
|
|
110
|
-
// 보내지 않은 Hash인 경우 추가
|
|
111
|
-
if(this.sent.hasKey(hash) == false) {
|
|
112
|
-
this.sent.add(hash);
|
|
113
|
-
new DataTextAgent().add(this.type, hash, text);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
exports.agent = new DataTextAgent();
|
|
118
|
-
exports.DBC = DBC;
|
|
119
|
-
exports.METHOD = METHOD;
|
|
120
|
-
exports.HTTPC_URL = HTTPC_URL;
|
|
121
|
-
exports.HTTPC_HOST = HTTPC_HOST;
|
|
122
|
-
exports.ERROR = ERROR;
|
|
123
|
-
exports.SERVICE = SERVICE;
|
|
124
|
-
exports.SQL = SQL;
|
|
125
|
-
exports.STACK = STACK;
|
|
126
|
-
exports.MESSAGE = MESSAGE;
|
|
127
|
-
exports.USERAGENT = USERAGENT;
|
|
128
|
-
exports.USER_AGENT_OS = USER_AGENT_OS;
|
|
129
|
-
exports.USER_AGENT_BROWSER = USER_AGENT_BROWSER;
|
|
130
|
-
exports.REFERER = REFERER;
|
|
131
|
-
exports.HTTP_DOMAIN = HTTP_DOMAIN;
|
|
132
|
-
exports.MTRACE_SPEC = MTRACE_SPEC;
|
|
133
|
-
exports.MTRACE_CALLER_URL = MTRACE_CALLER_URL;
|
|
134
|
-
exports.OKIND = OKIND;
|
|
135
|
-
exports.ONODE = ONODE;
|
package/lib/data/event-level.js
DELETED
|
@@ -1,15 +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 EventLevel = {
|
|
8
|
-
FATAL: Buffer.alloc(30),
|
|
9
|
-
WARNING: Buffer.alloc(20),
|
|
10
|
-
INFO: Buffer.alloc(10),
|
|
11
|
-
NONE: Buffer.alloc(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = EventLevel;
|
|
15
|
-
|
package/lib/data/test.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var IntSet = require('../util/intset') ,
|
|
2
|
-
TagCountPack = require('../pack/tagcount-pack');
|
|
3
|
-
const DataPackSender = require('./datapack-sender');
|
|
4
|
-
|
|
5
|
-
var Test = function() {
|
|
6
|
-
this.sent = new IntSet().setMax(10);
|
|
7
|
-
this.init()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Test.prototype.init = function() {
|
|
11
|
-
this.sent.add(1);
|
|
12
|
-
this.sent.add(2);
|
|
13
|
-
this.sent.add(3);
|
|
14
|
-
this.sent.add(4);
|
|
15
|
-
this.sent.add(5);
|
|
16
|
-
this.sent.add(6);
|
|
17
|
-
this.sent.add(7);
|
|
18
|
-
this.sent.add(8);
|
|
19
|
-
this.sent.add(9);
|
|
20
|
-
this.sent.add(10);
|
|
21
|
-
this.sent.add(11);
|
|
22
|
-
this.sent.add(12);
|
|
23
|
-
this.sent.add(13);
|
|
24
|
-
this.sent.add(14);
|
|
25
|
-
if(this.sent.hasKey(14) == false) {
|
|
26
|
-
console.log(this.sent.getLastValue())
|
|
27
|
-
this.sent.add(15);
|
|
28
|
-
}
|
|
29
|
-
var p = new TagCountPack()
|
|
30
|
-
p.category = 'aaaa'
|
|
31
|
-
p.pcode = 101
|
|
32
|
-
p.oid = 1
|
|
33
|
-
p.putTagString('tag1','tag1')
|
|
34
|
-
p.putTagString('tag2','tag2')
|
|
35
|
-
p.putTagString('tag3','tag3')
|
|
36
|
-
p.putTagString('tag4','tag4')
|
|
37
|
-
p.putTagString('tag5','tag5')
|
|
38
|
-
p.putTagString('tag6','tag6')
|
|
39
|
-
p.putInt('filed1' , 100)
|
|
40
|
-
p.putInt('filed2' , 200)
|
|
41
|
-
p.putInt('filed3' , 300)
|
|
42
|
-
p.putInt('filed4' , 400)
|
|
43
|
-
p.putInt('filed5' , 500)
|
|
44
|
-
p.putInt('filed6' , 600)
|
|
45
|
-
|
|
46
|
-
DataPackSender.sendTagCounterPack(p);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
exports.Test = new Test();
|
package/lib/data/zipprofile.js
DELETED
|
@@ -1,197 +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 conf = require('../conf/configure'),
|
|
8
|
-
secuMaster = require('../net/security-master'),
|
|
9
|
-
TcpRequestMgr = require('../net/tcprequest-mgr'),
|
|
10
|
-
DateUtil = require('./../util/dateutil'),
|
|
11
|
-
RequestQueue = require('../util/request-queue'),
|
|
12
|
-
DataPackSender = require('../data/datapack-sender'),
|
|
13
|
-
DataOutputX = require('../io/data-outputx'),
|
|
14
|
-
ZipPack = require('../pack/zip-pack'),
|
|
15
|
-
DataPackSender = require('../data/datapack-sender'),
|
|
16
|
-
Logger = require('../logger');
|
|
17
|
-
|
|
18
|
-
const zlib = require('zlib');
|
|
19
|
-
|
|
20
|
-
var profile_zip_enabled = conf.getProperty('profile_zip_enabled', false);
|
|
21
|
-
var profile_zip_max_buffer_size = conf.getProperty('profile_zip_max_buffer_size', 1024*1024);
|
|
22
|
-
var profile_zip_min_size = conf.getProperty('profile_zip_min_size', 100)
|
|
23
|
-
var profile_zip_queue_size = conf.getProperty('profile_zip_queue_size', 500);
|
|
24
|
-
var profile_zip_max_wait_time = conf.getProperty('profile_zip_max_wait_time', 1000);
|
|
25
|
-
var net_send_max_bytes = conf.getProperty('net_send_max_bytes', 5 * 1024 * 1024);
|
|
26
|
-
var debug_profile_zip_enabled = conf.getProperty('debug_profile_zip_enabled', false);
|
|
27
|
-
var debug_profile_zip_interval = conf.getProperty('debug_profile_zip_interval', 5000);
|
|
28
|
-
conf.on('profile_zip_enabled', function(newProperty) {
|
|
29
|
-
profile_zip_enabled = newProperty;
|
|
30
|
-
if (profile_zip_enabled) {
|
|
31
|
-
ZipProfile.getInstance().startProcessQueue();
|
|
32
|
-
} else {
|
|
33
|
-
ZipProfile.getInstance().stopProcessQueue();
|
|
34
|
-
ZipProfile.resetInstance();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
class ZipProfile {
|
|
39
|
-
constructor() {
|
|
40
|
-
if (ZipProfile.instance) {
|
|
41
|
-
return ZipProfile.instance;
|
|
42
|
-
}
|
|
43
|
-
this.queue = new RequestQueue(profile_zip_queue_size);
|
|
44
|
-
this.no_zip_sent = 0;
|
|
45
|
-
this.zip_sent = 0;
|
|
46
|
-
this.last_log = null;
|
|
47
|
-
this.buffer = Buffer.alloc(0);
|
|
48
|
-
this.packCount = 0;
|
|
49
|
-
this.first_time = null;
|
|
50
|
-
this.isProcessing = false;
|
|
51
|
-
ZipProfile.instance = this;
|
|
52
|
-
|
|
53
|
-
if (profile_zip_enabled) {
|
|
54
|
-
this.startProcessQueue();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static getInstance() {
|
|
59
|
-
if (!ZipProfile.instance) {
|
|
60
|
-
ZipProfile.instance = new ZipProfile();
|
|
61
|
-
}
|
|
62
|
-
return ZipProfile.instance;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static resetInstance() {
|
|
66
|
-
if(ZipProfile.instance){
|
|
67
|
-
ZipProfile.instance = null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
add(p){
|
|
72
|
-
var ok = this.queue.put(p);
|
|
73
|
-
if(!ok){
|
|
74
|
-
DataPackSender.sendPack(p);
|
|
75
|
-
this.no_zip_sent++;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async processQueue() {
|
|
80
|
-
this.isProcessing = true;
|
|
81
|
-
while (this.isProcessing) {
|
|
82
|
-
if(!profile_zip_enabled) { break; }
|
|
83
|
-
|
|
84
|
-
const p = await this.queue.getByTimeout(profile_zip_max_wait_time);
|
|
85
|
-
if(p) {
|
|
86
|
-
await this.append(p);
|
|
87
|
-
}else{
|
|
88
|
-
await this.sendAndClear();
|
|
89
|
-
}
|
|
90
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async append(p) {
|
|
95
|
-
var b = DataOutputX.toBytesPack(p);
|
|
96
|
-
if(b.length >= net_send_max_bytes){ return; }
|
|
97
|
-
|
|
98
|
-
this.buffer = Buffer.concat([this.buffer, b]);
|
|
99
|
-
this.packCount++;
|
|
100
|
-
|
|
101
|
-
if(!this.first_time){
|
|
102
|
-
this.first_time = p.time;
|
|
103
|
-
if(this.buffer.length >= profile_zip_max_buffer_size){
|
|
104
|
-
await this.sendAndClear();
|
|
105
|
-
}
|
|
106
|
-
}else{
|
|
107
|
-
if(this.buffer.length >= profile_zip_max_buffer_size || (p.time - this.first_time) >= conf.getProperty('profile_zip_max_wait_time', 5000)){
|
|
108
|
-
await this.sendAndClear();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async sendAndClear() {
|
|
114
|
-
if(this.buffer.length === 0){ return; }
|
|
115
|
-
|
|
116
|
-
var p = new ZipPack();
|
|
117
|
-
p.time = DateUtil.currentTime();
|
|
118
|
-
p.recordCount = this.packCount;
|
|
119
|
-
p.records = this.buffer;
|
|
120
|
-
|
|
121
|
-
await this.doZip(p);
|
|
122
|
-
if(debug_profile_zip_enabled){
|
|
123
|
-
if(debug_profile_zip_interval){
|
|
124
|
-
Logger.print('WHATAP-ZIP-DEBUG', `PROFILE status=${p.status} records=${p.recordCount} | ${this.buffer.length} => ${p.records.length} queue=${this.queue.size()}`, false)
|
|
125
|
-
} else {
|
|
126
|
-
this.zip_sent++;
|
|
127
|
-
var now = Date.now();
|
|
128
|
-
if(now > (this.last_log + debug_profile_zip_interval)){
|
|
129
|
-
this.last_log = now;
|
|
130
|
-
this.log(p);
|
|
131
|
-
this.zip_sent = 0;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
p.pcode = secuMaster.PCODE;
|
|
137
|
-
p.oid = secuMaster.OID;
|
|
138
|
-
p.okind = conf.OKIND;
|
|
139
|
-
p.onode = conf.ONODE;
|
|
140
|
-
|
|
141
|
-
TcpRequestMgr.addProfile(0, p);
|
|
142
|
-
|
|
143
|
-
this.buffer = Buffer.alloc(0);
|
|
144
|
-
this.first_time = 0;
|
|
145
|
-
this.packCount = 0;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
log(p){
|
|
149
|
-
try{
|
|
150
|
-
var sb = `PROFILE `;
|
|
151
|
-
sb += `zip_sent=${this.zip_sent}`;
|
|
152
|
-
sb += ` records=${p.records}`;
|
|
153
|
-
sb += ` | =${this.buffer.length} => ${p.records.length}`;
|
|
154
|
-
sb += ` queue=${this.queue.size()}`;
|
|
155
|
-
if (this.no_zip_sent > 0) {
|
|
156
|
-
sb += ` no_zip_sent=${this.no_zip_sent}`;
|
|
157
|
-
}
|
|
158
|
-
Logger.print('WHATAP-ZIP-DEBUG', sb, false);
|
|
159
|
-
}catch (e) {
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async doZip(p){
|
|
164
|
-
if(p.status !== 0){ return; }
|
|
165
|
-
if(p.records.length < profile_zip_min_size){ return; }
|
|
166
|
-
p.status = 1;
|
|
167
|
-
|
|
168
|
-
try{
|
|
169
|
-
p.records = await this._doZip(p.records);
|
|
170
|
-
}catch (e) {
|
|
171
|
-
Logger.print('WHATAP-ZIP-ERROR', 'Error occurred during compression.', false);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
_doZip(data) {
|
|
176
|
-
return new Promise((resolve, reject) => {
|
|
177
|
-
zlib.gzip(data, (err, buffer) => {
|
|
178
|
-
if (err) {
|
|
179
|
-
reject(err);
|
|
180
|
-
} else {
|
|
181
|
-
resolve(buffer);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
startProcessQueue() {
|
|
188
|
-
if (!this.isProcessing) {
|
|
189
|
-
this.processQueue()
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
stopProcessQueue() {
|
|
193
|
-
this.isProcessing = false;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
module.exports = ZipProfile;
|
package/lib/env/constants.js
DELETED
|
@@ -1,21 +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 numType = {
|
|
8
|
-
INT8_MIN : -128,
|
|
9
|
-
INT8_MAX : 127,
|
|
10
|
-
INT16_MIN : -32768,
|
|
11
|
-
INT16_MAX : 32767,
|
|
12
|
-
INT24_MIN : -8388608,
|
|
13
|
-
INT24_MAX : 8388607,
|
|
14
|
-
INT32_MIN : -2147483648,
|
|
15
|
-
INT32_MAX : 2147483647,
|
|
16
|
-
INT40_MIN : -549755813888,
|
|
17
|
-
INT40_MAX : 549755813887,
|
|
18
|
-
INT64_MIN : -4503599627370496,
|
|
19
|
-
INT64_MAX : 4503599627370495
|
|
20
|
-
};
|
|
21
|
-
module.exports.numType = numType;
|