whatap 1.0.2 → 1.0.3-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.
Files changed (198) hide show
  1. package/README.md +77 -33
  2. package/agent/darwin/arm64/whatap_nodejs +0 -0
  3. package/agent/linux/amd64/whatap_nodejs +0 -0
  4. package/agent/linux/arm64/whatap_nodejs +0 -0
  5. package/build.txt +4 -0
  6. package/lib/conf/config-default.js +3 -10
  7. package/lib/conf/configure.js +349 -369
  8. package/lib/conf/license.js +1 -1
  9. package/lib/control/packagectr-helper.js +3 -34
  10. package/lib/core/agent.js +888 -176
  11. package/lib/core/interceptor.js +6 -6
  12. package/lib/core/shimmer.js +36 -82
  13. package/lib/counter/counter-manager.js +8 -79
  14. package/lib/counter/task/activetransaction.js +17 -68
  15. package/lib/io/data-inputx.js +3 -13
  16. package/lib/io/data-outputx.js +206 -268
  17. package/lib/logger.js +6 -6
  18. package/lib/net/security-master.js +20 -139
  19. package/lib/observers/apollo-server-observer.js +27 -33
  20. package/lib/observers/global-observer.js +80 -155
  21. package/lib/observers/http-observer.js +236 -666
  22. package/lib/observers/ioredis-observer.js +294 -0
  23. package/lib/observers/maria-observer.js +362 -204
  24. package/lib/observers/mongodb-observer.js +226 -169
  25. package/lib/observers/mongoose-observer.js +323 -518
  26. package/lib/observers/mssql-observer.js +418 -177
  27. package/lib/observers/mysql-observer.js +449 -342
  28. package/lib/observers/mysql2-observer.js +358 -396
  29. package/lib/observers/oracle-observer.js +384 -559
  30. package/lib/observers/pgsql-observer.js +489 -231
  31. package/lib/observers/prisma-observer.js +92 -303
  32. package/lib/observers/process-observer.js +35 -79
  33. package/lib/observers/redis-observer.js +331 -166
  34. package/lib/observers/socket.io-observer.js +187 -226
  35. package/lib/observers/websocket-observer.js +301 -175
  36. package/lib/pack/counter-pack.js +0 -3
  37. package/lib/pack/log-sink-pack.js +52 -14
  38. package/lib/pack/tagcount-pack.js +4 -4
  39. package/lib/{counter/task → system}/gc-action.js +74 -27
  40. package/lib/trace/trace-context-manager.js +25 -113
  41. package/lib/trace/trace-context.js +7 -21
  42. package/lib/trace/trace-httpc.js +11 -17
  43. package/lib/trace/trace-sql.js +21 -29
  44. package/lib/udp/async_sender.js +119 -0
  45. package/lib/udp/index.js +17 -0
  46. package/lib/udp/packet_enum.js +52 -0
  47. package/lib/udp/packet_queue.js +69 -0
  48. package/lib/udp/packet_type_enum.js +33 -0
  49. package/lib/udp/param_def.js +72 -0
  50. package/lib/udp/udp_session.js +336 -0
  51. package/lib/util/escape-literal-sql.js +5 -5
  52. package/lib/util/hashutil.js +18 -18
  53. package/lib/util/keygen.js +3 -0
  54. package/lib/util/linkedset.js +2 -1
  55. package/lib/util/nodeutil.js +1 -2
  56. package/lib/util/sql-util.js +178 -0
  57. package/lib/util/trace-helper.js +91 -0
  58. package/lib/util/transfer.js +58 -0
  59. package/lib/value/map-value.js +2 -3
  60. package/package.json +5 -9
  61. package/whatap.conf +4 -1
  62. package/lib/conf/conf-sys-mon.js +0 -101
  63. package/lib/control/cmd-config.js +0 -24
  64. package/lib/control/control-handler.js +0 -367
  65. package/lib/core/request-agent.js +0 -27
  66. package/lib/counter/meter/meter-activex.js +0 -67
  67. package/lib/counter/meter/meter-httpc.js +0 -57
  68. package/lib/counter/meter/meter-resource.js +0 -9
  69. package/lib/counter/meter/meter-service.js +0 -168
  70. package/lib/counter/meter/meter-socket.io.js +0 -51
  71. package/lib/counter/meter/meter-sql.js +0 -71
  72. package/lib/counter/meter/meter-users.js +0 -58
  73. package/lib/counter/meter.js +0 -183
  74. package/lib/counter/task/agentinfo.js +0 -107
  75. package/lib/counter/task/gcstat.js +0 -34
  76. package/lib/counter/task/heapmem.js +0 -25
  77. package/lib/counter/task/httpc.js +0 -76
  78. package/lib/counter/task/metering-info.js +0 -125
  79. package/lib/counter/task/proc-cpu.js +0 -29
  80. package/lib/counter/task/realtimeuser.js +0 -31
  81. package/lib/counter/task/res/systemECSTask.js +0 -39
  82. package/lib/counter/task/res/systemKubeTask.js +0 -53
  83. package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
  84. package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
  85. package/lib/counter/task/res-sys-cpu.js +0 -62
  86. package/lib/counter/task/service.js +0 -202
  87. package/lib/counter/task/socketio.js +0 -30
  88. package/lib/counter/task/sql.js +0 -105
  89. package/lib/counter/task/systemperf.js +0 -43
  90. package/lib/data/datapack-sender.js +0 -289
  91. package/lib/data/dataprofile-agent.js +0 -162
  92. package/lib/data/datatext-agent.js +0 -135
  93. package/lib/data/event-level.js +0 -15
  94. package/lib/data/test.js +0 -49
  95. package/lib/data/zipprofile.js +0 -197
  96. package/lib/env/constants.js +0 -21
  97. package/lib/error/error-handler.js +0 -437
  98. package/lib/kube/kube-client.js +0 -144
  99. package/lib/lang/text-types.js +0 -58
  100. package/lib/logsink/line-log-util.js +0 -87
  101. package/lib/logsink/line-log.js +0 -12
  102. package/lib/logsink/log-sender.js +0 -78
  103. package/lib/logsink/log-tracer.js +0 -40
  104. package/lib/logsink/sender-util.js +0 -56
  105. package/lib/logsink/zip/zip-send.js +0 -177
  106. package/lib/net/netflag.js +0 -55
  107. package/lib/net/receiver.js +0 -66
  108. package/lib/net/sender.js +0 -141
  109. package/lib/net/tcp-return.js +0 -18
  110. package/lib/net/tcp-session.js +0 -286
  111. package/lib/net/tcpreq-client-proxy.js +0 -70
  112. package/lib/net/tcprequest-mgr.js +0 -58
  113. package/lib/observers/cluster-observer.js +0 -22
  114. package/lib/observers/express-observer.js +0 -215
  115. package/lib/observers/file-observer.js +0 -184
  116. package/lib/observers/grpc-observer.js +0 -336
  117. package/lib/observers/memcached-observer.js +0 -56
  118. package/lib/observers/mongo-observer.js +0 -317
  119. package/lib/observers/net-observer.js +0 -77
  120. package/lib/observers/promise-observer.js +0 -31
  121. package/lib/observers/schedule-observer.js +0 -67
  122. package/lib/observers/stream-observer.js +0 -19
  123. package/lib/observers/thrift-observer.js +0 -197
  124. package/lib/pack/activestack-pack.js +0 -55
  125. package/lib/pack/apenum.js +0 -8
  126. package/lib/pack/errorsnap-pack.js +0 -69
  127. package/lib/pack/event-pack.js +0 -54
  128. package/lib/pack/hitmap-pack.js +0 -63
  129. package/lib/pack/hitmap-pack1.js +0 -152
  130. package/lib/pack/netstat.js +0 -15
  131. package/lib/pack/otype.js +0 -7
  132. package/lib/pack/profile-pack.js +0 -49
  133. package/lib/pack/realtimeuser-pack.js +0 -41
  134. package/lib/pack/stat-general-pack.js +0 -96
  135. package/lib/pack/staterror-pack.js +0 -120
  136. package/lib/pack/stathttpc-pack.js +0 -66
  137. package/lib/pack/stathttpc-rec.js +0 -78
  138. package/lib/pack/statremote-pack.js +0 -46
  139. package/lib/pack/statservice-pack.js +0 -63
  140. package/lib/pack/statservice-pack1.js +0 -88
  141. package/lib/pack/statservice-rec.js +0 -292
  142. package/lib/pack/statservice-rec_dep.js +0 -151
  143. package/lib/pack/statsql-pack.js +0 -69
  144. package/lib/pack/statsql-rec.js +0 -100
  145. package/lib/pack/statuseragent-pack.js +0 -44
  146. package/lib/pack/tagctr.js +0 -15
  147. package/lib/pack/text-pack.js +0 -50
  148. package/lib/pack/time-count.js +0 -25
  149. package/lib/pack/websocket.js +0 -15
  150. package/lib/pack/zip-pack.js +0 -70
  151. package/lib/pii/pii-item.js +0 -31
  152. package/lib/pii/pii-mask.js +0 -174
  153. package/lib/plugin/plugin-loadermanager.js +0 -57
  154. package/lib/plugin/plugin.js +0 -75
  155. package/lib/service/tx-record.js +0 -332
  156. package/lib/stat/stat-error.js +0 -116
  157. package/lib/stat/stat-httpc.js +0 -98
  158. package/lib/stat/stat-remote-ip.js +0 -46
  159. package/lib/stat/stat-remote-ipurl.js +0 -88
  160. package/lib/stat/stat-sql.js +0 -113
  161. package/lib/stat/stat-tranx.js +0 -58
  162. package/lib/stat/stat-tx-caller.js +0 -160
  163. package/lib/stat/stat-tx-domain.js +0 -111
  164. package/lib/stat/stat-tx-referer.js +0 -112
  165. package/lib/stat/stat-useragent.js +0 -48
  166. package/lib/stat/timingsender.js +0 -76
  167. package/lib/step/activestack-step.js +0 -38
  168. package/lib/step/dbc-step.js +0 -36
  169. package/lib/step/http-stepx.js +0 -67
  170. package/lib/step/message-step.js +0 -40
  171. package/lib/step/method-stepx.js +0 -45
  172. package/lib/step/resultset-step.js +0 -40
  173. package/lib/step/securemsg-step.js +0 -44
  174. package/lib/step/socket-step.js +0 -46
  175. package/lib/step/sql-stepx.js +0 -68
  176. package/lib/step/sqlxtype.js +0 -16
  177. package/lib/step/step.js +0 -66
  178. package/lib/step/stepenum.js +0 -54
  179. package/lib/topology/link.js +0 -63
  180. package/lib/topology/nodeinfo.js +0 -123
  181. package/lib/topology/status-detector.js +0 -111
  182. package/lib/util/anylist.js +0 -103
  183. package/lib/util/cardinality/hyperloglog.js +0 -106
  184. package/lib/util/cardinality/murmurhash.js +0 -31
  185. package/lib/util/cardinality/registerset.js +0 -75
  186. package/lib/util/errordata.js +0 -21
  187. package/lib/util/iputil_x.js +0 -527
  188. package/lib/util/kube-util.js +0 -73
  189. package/lib/util/paramsecurity.js +0 -80
  190. package/lib/util/pre-process.js +0 -13
  191. package/lib/util/process-seq.js +0 -166
  192. package/lib/util/property-util.js +0 -36
  193. package/lib/util/request-queue.js +0 -70
  194. package/lib/util/requestdouble-queue.js +0 -72
  195. package/lib/util/resourceprofile.js +0 -157
  196. package/lib/util/stop-watch.js +0 -30
  197. package/lib/util/system-util.js +0 -10
  198. package/lib/util/userid-util.js +0 -57
@@ -1,332 +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 DataOutputX = require('../io/data-outputx'),
8
- DataInputX = require('../io/data-inputx'),
9
- Long = require('long') ,
10
- EventLevel = require('../data/event-level');
11
- function TxRecord() {
12
- this.seq = Long.ZERO;
13
- this.endTime =0;
14
- this.service = 0;
15
- this.elapsed = 0;
16
- this.error = Long.ZERO;
17
- this.cpuTime = 0;
18
- this.malloc = 0;
19
-
20
- this.sqlCount = 0;
21
- this.sqlTime = 0;
22
- this.sqlFetchCount = 0;
23
- this.sqlFetchTime = 0;
24
-
25
- this.httpcCount = 0;
26
- this.httpcTime = 0;
27
- this.active = false;
28
- this.steps_data_pos = 0;
29
- this.cipher = 0;
30
-
31
- this.ipaddr = 0;
32
- this.userid = Long.ZERO;
33
- this.userAgent = 0;
34
- this.referer = 0;
35
- this.status = 0;
36
-
37
- this.mtid = Long.ZERO;
38
- this.mdepth = 0;
39
- this.mcaller = Long.ZERO;
40
- this.mcaller_txid = Long.ZERO;
41
-
42
- this.mcaller_pcode = 0;
43
- this.mcaller_okind = 0;
44
- this.mcaller_oid = 0;
45
- this.mcaller_spec = 0;
46
- this.mcaller_url = 0;
47
- this.mthis_spec = 0;
48
-
49
- this.http_method = 0;
50
-
51
- this.domain = 0;
52
- this.fields = [];
53
-
54
- this.login=0;
55
- this.errorLevel=0;
56
-
57
- this.oid=0;
58
- this.okind=0;
59
- this.onode=0;
60
-
61
- this.custid=null;
62
- this.dbcTime=0;
63
- this.apdex=0;
64
-
65
- this.mcallerStepId = Long.ZERO;
66
- this.originUrl = null;
67
-
68
- this.step_split_count = 0;
69
-
70
- this.methodCount = 0;
71
- this.methodTime = 0;
72
-
73
- this.appctx = "";
74
- this.txName = "";
75
- this.error_class = "";
76
- this.error_message = "";
77
- }
78
- TxRecord.prototype.getServiceType = function() {return 0;};
79
-
80
- TxRecord.prototype.write = function(dout) {
81
- dout.writeByte(10); //version
82
-
83
- var o = new DataOutputX();
84
- o.writeLong(this.seq);
85
- o.writeDecimal(this.endTime);
86
- o.writeDecimal(this.service);
87
- o.writeDecimal(this.elapsed);
88
- o.writeDecimal(this.error);
89
- o.writeDecimal(this.cpuTime);
90
- o.writeDecimal(this.malloc);
91
-
92
- o.writeDecimal(this.sqlCount);
93
- o.writeDecimal(this.sqlTime);
94
- o.writeDecimal(this.sqlFetchCount);
95
- o.writeDecimal(this.sqlFetchTime);
96
-
97
- o.writeDecimal(this.httpcCount);
98
- o.writeDecimal(this.httpcTime);
99
-
100
- o.writeBoolean(this.active);
101
- o.writeDecimal(this.steps_data_pos);
102
- o.writeDecimal(this.cipher);
103
-
104
- o.writeInt(this.ipaddr);
105
- o.writeDecimal(this.userid);
106
- o.writeDecimal(this.userAgent);
107
- o.writeDecimal(this.referer);
108
- o.writeDecimal(this.status);
109
-
110
- if(this.mtid.isZero()==false){
111
- o.writeByte(1);
112
- o.writeDecimal(this.mtid);
113
- o.writeDecimal(this.mdepth);
114
- o.writeDecimal(this.mcaller);
115
- }else{
116
- o.writeByte(0);
117
- }
118
- if(this.mcaller_pcode!=0) {
119
- o.writeByte(6);
120
- o.writeDecimal(this.mcaller_pcode);
121
- o.writeDecimal(this.mcaller_okind);
122
- o.writeDecimal(this.mcaller_oid);
123
- o.writeDecimal(this.mcaller_spec);
124
- o.writeDecimal(this.mcaller_url);
125
- o.writeDecimal(this.mthis_spec);//보통 0, 서버에서 셋팅
126
- }else {
127
- o.writeByte(0);
128
- }
129
-
130
- o.writeByte(this.http_method);
131
- o.writeDecimal(this.domain);
132
-
133
- if (this.fields == null || this.fields.length==0) {
134
- o.writeByte(0);
135
- } else {
136
- var sz = this.fields.length;
137
- o.writeByte(sz);
138
- for (var i = 0; i < sz; i++) {
139
- o.writeByte(this.fields[i].id);
140
- o.writeText(this.fields[i].value);
141
- }
142
- }
143
- o.writeDecimal(this.login);
144
- o.writeByte(this.errorLevel);
145
-
146
- // 2018.12.28
147
- o.writeDecimal(this.oid);
148
- o.writeDecimal(this.okind);
149
- o.writeDecimal(this.onode);
150
-
151
- o.writeText(this.custid);
152
- o.writeDecimal(this.dbcTime);
153
- o.writeByte(this.apdex);
154
-
155
- o.writeDecimal(this.mcallerStepId);
156
- o.writeText(this.originUrl);
157
-
158
- o.writeDecimal(this.step_split_count);
159
-
160
- o.writeDecimal(this.methodCount);
161
- o.writeDecimal(this.methodTime);
162
-
163
- o.writeText(this.appctx);
164
- o.writeText(this.txName);
165
- o.writeText(this.error_class);
166
- o.writeText(this.error_message);
167
-
168
- ////////////// BLOB ///////////////
169
- dout.writeBlob(o.toByteArray());
170
- };
171
-
172
- TxRecord.prototype.read = function(din) {
173
- var ver = din.readByte();
174
- if(ver <10){
175
- throw new Error('TxRecord has invalid version='+ver);
176
- }
177
- var i = new DataInputX(din.readBlob());
178
- this.seq = i.readLong();
179
- this.endTime = i.readDecNumber();
180
- this.service = i.readDecNumber();
181
- this.elapsed = i.readDecNumber();
182
- this.error = i.readDecimal();
183
-
184
- this.cpuTime = i.readDecNumber();
185
- this.malloc = i.readDecNumber();
186
-
187
- this.sqlCount = i.readDecNumber();
188
- this.sqlTime = i.readDecNumber();
189
- this.sqlFetchCount = i.readDecNumber();
190
- this.sqlFetchTime = i.readDecNumber();
191
-
192
- this.httpcCount = i.readDecNumber();
193
- this.httpcTime = i.readDecNumber();
194
-
195
- this.active = i.readBoolean();
196
- this.steps_data_pos = i.readDecNumber();
197
- this.cipher = i.readDecNumber();
198
-
199
- this.ipaddr = i.readInt();
200
- this.userid = i.readDecLong();
201
- this.userAgent = i.readDecNumber();
202
- this.referer = i.readDecNumber();
203
- this.status = i.readDecNumber();
204
-
205
- if(i.readByte() >0){
206
- this.mtid = i.readDecLong();
207
- this.mdepth = i.readDecNumber();
208
- this.mcaller_txid = i.readDecLong();
209
- }
210
-
211
- switch (i.readByte()) {
212
- case 1:
213
- this.mcaller_pcode = i.readDecNumber();
214
- break;
215
- case 3:
216
- this.mcaller_pcode = i.readDecNumber();
217
- this.mcaller_spec = i.readDecNumber();
218
- this.mcaller_url = i.readDecNumber();
219
- break;
220
- case 4:
221
- this.mcaller_pcode = i.readDecNumber();
222
- this.mcaller_spec = i.readDecNumber();
223
- this.mcaller_url = i.readDecNumber();
224
- this.mthis_spec = i.readDecNumber();
225
- break;
226
- case 5:
227
- this.mcaller_pcode = i.readDecNumber();
228
- this.mcaller_oid = i.readDecNumber();
229
- this.mcaller_spec = i.readDecNumber();
230
- this.mcaller_url = i.readDecNumber();
231
- this.mthis_spec = i.readDecNumber();
232
- break;
233
- case 6:
234
- this.mcaller_pcode = i.readDecNumber();
235
- this.mcaller_okind = i.readDecNumber();
236
- this.mcaller_oid = i.readDecNumber();
237
- this.mcaller_spec = i.readDecNumber();
238
- this.mcaller_url = i.readDecNumber();
239
- this.mthis_spec = i.readDecNumber();
240
- break;
241
- }
242
- this.http_method = i.readByte();
243
- this.domain = i.readDecNumber();
244
-
245
- var n = i.readByte();
246
- if (n > 0) {
247
- this.fields = new Array(n);
248
- for (var c = 0; c < n; c++) {
249
- var id = i.readByte();
250
- var value = i.readText();
251
- this.fields[i] = {
252
- id: id,
253
- value: value
254
- };
255
- }
256
- }
257
-
258
- if (i.available() > 0) {
259
- this.login = i.readDecNumber();
260
- }
261
- if (i.available() > 0) {
262
- this.errorLevel = i.readByte();
263
- } else {
264
- if (this.error != 0) {
265
- this.errorLevel = EventLevel.WARNING;
266
- }
267
- }
268
- if(i.available()>0) {
269
- this.oid = i.readDecNumber();
270
- this.okind = i.readDecNumber();
271
- this.onode = i.readDecNumber();
272
- }
273
-
274
- if (i.available() > 0) {
275
- this.custid = i.readText();
276
- }
277
- if (i.available() > 0) {
278
- this.dbcTime = i.readDecNumber();
279
- }
280
- if (i.available() > 0) {
281
- this.apdex = i.readByte();
282
- }
283
-
284
- if(i.available()>0) {
285
- this.mcallerStepId=i.readDecNumber();
286
- this.originUrl=i.readText();
287
- }
288
-
289
- if (i.available() > 0) {
290
- this.step_split_count = i.readDecimal();
291
- }
292
- if (i.available() > 0) {
293
- this.methodCount = i.readDecimal();
294
- this.methodTime = i.readDecimal();
295
- }
296
- if(i.available()>0) {
297
- this.appctx=i.readText();
298
- }
299
- if(i.available()>0) {
300
- this.txName=i.readText();
301
- }
302
- if(i.available()>0) {
303
- this.error_class = i.readText();
304
- this.error_message = i.readText();
305
- }
306
-
307
- return this;
308
- };
309
-
310
- TxRecord.prototype.toBytes = function() {
311
- var dout = new DataOutputX();
312
- this.write(dout);
313
- return dout.toByteArray();
314
- };
315
-
316
- TxRecord.prototype.toObject = function(b) {
317
- var din = new DataInputX(b);
318
- this.read(din);
319
- return service;
320
- };
321
-
322
- TxRecord.HTTP_METHOD={"GET":1,"POST":2,"PUT":3,"DELETE":4,"PATCH":5,"OPTIONS":6,"HEAD":7,"TRACE":8};
323
- TxRecord.WEB_GET = 1;
324
- TxRecord.WEB_POST = 2;
325
- TxRecord.WEB_PUT = 3;
326
- TxRecord.WEB_DELETE = 4;
327
- TxRecord.WEB_PATCH = 5;
328
- TxRecord.WEB_OPTIONS = 6;
329
- TxRecord.WEB_HEAD = 7;
330
- TxRecord.WEB_TRACE = 8;
331
-
332
- module.exports = TxRecord;
@@ -1,116 +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 ErrorData = require('../util/errordata'),
9
- BitUtil = require('../util/bitutil'),
10
- ErrorSnapPack1 = require('../pack/errorsnap-pack'),
11
- StatErrorPack = require('../pack/staterror-pack').StatErrorPack,
12
- ErrorRec = require('../pack/staterror-pack').ErrorRec,
13
- hashUtil = require('../util/hashutil'),
14
- LinkedMap = require('../util/linkedmap'),
15
- DataTextAgent = require('../data/datatext-agent'),
16
- Logger = require('../logger'),
17
- Long = require('long');
18
-
19
-
20
- var DataPackSender = require('../data/datapack-sender');
21
-
22
- var ERROR_SNAP_SEQ = Long.fromNumber(Date.now());
23
- var TABLE_MAX_SIZE = 1000;
24
-
25
- function StatError() {
26
- this.conf = require('../conf/configure');
27
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
28
- this.table.hash = function (k) {
29
- if(k._hash_){
30
- return k._hash_;
31
- }
32
- var result = 1;
33
- result = 31 * result + k.class;
34
- result = 31 * result + k.service;
35
-
36
- k._hash_=result;
37
- return result;
38
- }
39
- this.table.equals = function (k1,k2) {
40
- return k1.class === k2.class && k1.service === k2.service;
41
- }
42
- this.table.create=function(key){
43
- if(this.isFull()) {
44
- return null;
45
- }
46
- rec = new ErrorRec();
47
- rec.classHash = key.class;
48
- rec.service = key.service;
49
- return rec;
50
- }
51
- this.error = {};
52
- }
53
-
54
- function nextErrorSnapSeq(){
55
- ERROR_SNAP_SEQ = ERROR_SNAP_SEQ.add(1);
56
- return ERROR_SNAP_SEQ;
57
- }
58
-
59
- // StatError.prototype.addErrorForStep = function(thr, dbc, service, steps, stackTrace) {
60
- // var error_data = new ErrorData(thr, 0, txUrlHash, profile, true); // notdol: error데이터 객체를 만드는 의미가 없음
61
- // var error_snap_pack = new ErrorSnapPack1(); // notdol: errorSnappack을 만드는 의미가 없음
62
- // error_snap_pack.setProfile(error_data.profile);
63
-
64
- // var rec = this.table.get({class: dbc, service : service});
65
- // if(rec){
66
- // rec.count++;
67
- // }
68
- // };
69
- StatError.prototype.addError = function(class1, msg, txUrlHash, appendTextType, appendTextHash) {
70
- try {
71
- if(typeof class1 ==='number'){
72
- class1 = class1.toString();
73
- }
74
- var classHash = hashUtil.hashFromString(class1);
75
- DataTextAgent.ERROR.add(classHash, class1);
76
-
77
- var msgHash = hashUtil.hashFromString(msg);
78
- DataTextAgent.ERROR.add(msgHash, msg);
79
-
80
- var key = {class: classHash, service : txUrlHash};
81
- var rec = this.table.intern(key);
82
- if (rec) {
83
- rec.msg = msgHash;
84
- rec.count++;
85
- if (appendTextType && rec.snapSeq == 0 && this.conf.error_snap_enabled===true) {
86
- var p = new ErrorSnapPack1();
87
- p.seq = nextErrorSnapSeq();
88
- rec.snapSeq = p.seq;
89
- rec.msg = msgHash;
90
-
91
- p.append_type = appendTextType;
92
- p.append_hash = appendTextHash;
93
- DataPackSender.sendErrorSnapPack(p);
94
- }
95
- }
96
- return BitUtil.composite(classHash,msgHash);
97
- } catch(e) {
98
- Logger.printError('WHATAP-996', 'StatError (addError)', e, false);
99
- }
100
- return Long.ZERO;
101
- };
102
- StatError.prototype.send = function(now) {
103
- if (this.table.size() === 0)
104
- return;
105
-
106
- var statError = new StatErrorPack().setRecords(this.table.size(), this.table.values());
107
- statError.time = now;
108
- this.table.clear();
109
-
110
- DataPackSender.sendStatErrorPack(statError);
111
- };
112
- StatError.prototype.clear = function () {
113
- this.table.clear();
114
- };
115
-
116
- module.exports = new StatError();
@@ -1,98 +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 LinkedMap = require('../util/linkedmap'),
8
- StatHttpcPack = require('../pack/stathttpc-pack'),
9
- HttpcRec = require('../pack/stathttpc-rec'),
10
- DataPackSender = require('../data/datapack-sender'),
11
- Logger = require('../logger');
12
-
13
- const TABLE_MAX_SIZE = 5000;
14
-
15
- function HTTPC(url, host, port) {
16
- this.url = url || 0;
17
- this.host = host || 0;
18
- this.port = port || 0;
19
- }
20
-
21
- HTTPC.prototype.hashCode = function () {
22
- var prime = 31;
23
- var result = 1;
24
- result = prime * result + this.host;
25
- result = prime * result + this.port;
26
- result = prime * result + this.url;
27
- return result;
28
- };
29
- HTTPC.prototype.equals = function (other) {
30
- if(this === other) {
31
- return true;
32
- }
33
- if(other == null) {
34
- return false;
35
- }
36
- return this.host === other.host && this.url === other.url && this.port === other.port;
37
- };
38
-
39
- function StatHttpc() {
40
- if(typeof StatHttpc.instance === 'object') {
41
- return StatHttpc.instance;
42
- }
43
-
44
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
45
- this.table.create = function (key) {
46
- if(this.size() >= TABLE_MAX_SIZE) {
47
- return null;
48
- }
49
- var rec = new HttpcRec();
50
- rec.url = key.url;
51
- rec.host = key.host;
52
- rec.port = key.port;
53
- rec.time_min = Number.MAX_SAFE_INTEGER;
54
- return rec;
55
- };
56
- StatHttpc.instance = this;
57
- }
58
-
59
- StatHttpc.prototype.getHttpc = function (url, host, port) {
60
- return this.table.intern(new HTTPC(url, host, port));
61
- };
62
- StatHttpc.prototype.addHttpcTime = function (service_hash, httpc_url_hash, httpc_host, httpc_port, time, isErr) {
63
-
64
- try {
65
- if(httpc_url_hash === 0) {
66
- return;
67
- }
68
-
69
- var httpcRec = this.getHttpc(httpc_url_hash, httpc_host, httpc_port);
70
- if(httpcRec != null) {
71
- httpcRec.count_total++;
72
- httpcRec.time_sum +=time;
73
- httpcRec.time_std +=time * time;
74
- httpcRec.time_max = Math.max(httpcRec.time_max, time);
75
- httpcRec.time_min = Math.min(httpcRec.time_min, time);
76
- if (isErr) {
77
- httpcRec.count_error++;
78
- }
79
- httpcRec.service = service_hash;
80
- }
81
- } catch(e) {
82
- Logger.printError("WHATAP-610", "StatHttpC addHttpcTime error", e, false);
83
- }
84
- };
85
- StatHttpc.prototype.send = function (now) {
86
- if(this.table.size() === 0) {
87
- return;
88
- }
89
- var p = new StatHttpcPack().setRecords(this.table.size(), this.table.values());
90
- p.time = now;
91
- this.table.clear();
92
- DataPackSender.sendStatHttpcPack(p);
93
- };
94
- StatHttpc.prototype.clear = function () {
95
- this.table.clear();
96
- };
97
-
98
- module.exports = new StatHttpc();
@@ -1,46 +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 StatRemoteIpPack = require('../pack/statremote-pack'),
8
- DataPackSender = require('../data/datapack-sender');
9
-
10
- var TABLE_MAX_SIZE = 70000;
11
-
12
- function StatRemoteIp() {
13
- if(typeof StatRemoteIp.instance === 'object') {
14
- return StatRemoteIp.instance;
15
- }
16
-
17
- this.table = new StatRemoteIpPack();
18
- this.table.iptable.setMax(TABLE_MAX_SIZE);
19
-
20
- StatRemoteIp.instance = this;
21
- }
22
-
23
- StatRemoteIp.prototype.incRemoteIp = function (ip) {
24
- if(ip) {
25
- this.table.iptable.addNoOver(ip,1);
26
- }
27
- };
28
- StatRemoteIp.prototype.send = function (now) {
29
- if(this.table.iptable.size() === 0) {
30
- return;
31
- }
32
-
33
- var p = this.table;
34
- p.time = now;
35
- DataPackSender.sendStatRemoteIpPack(p);
36
-
37
- this.table = new StatRemoteIpPack();
38
- this.table.iptable.setMax(TABLE_MAX_SIZE);
39
- };
40
- StatRemoteIp.prototype.clear = function () {
41
- this.table.iptable.clear();
42
- };
43
-
44
- module.exports = new StatRemoteIp();
45
-
46
-
@@ -1,88 +0,0 @@
1
- const StatGeneralPack = require('../pack/stat-general-pack');
2
- const LongKeyLinkedMap = require('../util/longkey-linkedmap');
3
- const TimeCount = require('../pack/time-count');
4
- const conf = require('../conf/configure');
5
- const BitUtil = require('../util/bitutil');
6
- const ZipProfile = require('../data/zipprofile');
7
- const DataPackSender = require('../data/datapack-sender');
8
- const AnyList = require('../util/anylist');
9
-
10
- var TABLE_MAX_SIZE = 10000;
11
-
12
- function StatRemoteIpurl() {
13
- if (typeof StatRemoteIpurl.instance === 'object') {
14
- return StatRemoteIpurl.instance;
15
- }
16
-
17
- this.TABLE_MAX_SIZE = TABLE_MAX_SIZE;
18
- this.table = new LongKeyLinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
19
- this.table.create = function (key) {
20
- return new TimeCount();
21
- };
22
-
23
- StatRemoteIpurl.instance = this;
24
- }
25
-
26
- StatRemoteIpurl.prototype.getService = function (ip, url_hash) {
27
- var key = BitUtil.composite(ip, url_hash);
28
- if (this.table.size() < conf.getProperty('stat_ipurl_max_count', 10000)) {
29
- return this.table.intern(key);
30
- } else {
31
- return this.table.get(key);
32
- }
33
- };
34
-
35
- StatRemoteIpurl.prototype.send = function (now) {
36
- if (this.table.size() === 0) return;
37
-
38
- var currTable = this.table;
39
- var sz = Math.max(this.TABLE_MAX_SIZE, conf.getProperty('stat_ipurl_max_count', 10000));
40
- this.table = new LongKeyLinkedMap(sz + 1, 1).setMax(conf.getProperty('stat_ipurl_max_count', 10000));
41
- this.table.create = function (key) {
42
- return new TimeCount();
43
- };
44
-
45
- var rsize = this.table.size();
46
- var ip = new AnyList(AnyList.INT, rsize);
47
- var url = new AnyList(AnyList.INT, rsize);
48
- var count = new AnyList(AnyList.INT, rsize);
49
- var error = new AnyList(AnyList.INT, rsize);
50
- var time = new AnyList(AnyList.LONG, rsize);
51
-
52
- var entries = currTable.entries();
53
- var i = 0;
54
- while(entries.hasMoreElements()){
55
- var ent = entries.nextElement();
56
- var k = ent.getKey();
57
- var v = ent.getValue();
58
-
59
- ip.put(i, BitUtil.getHigh(k));
60
- url.put(i, BitUtil.getLow(k));
61
- count.put(i, v.count);
62
- error.put(i, v.error);
63
- time.put(i, v.time);
64
- i++;
65
- }
66
-
67
- const out = new StatGeneralPack();
68
- out.put("ip", ip);
69
- out.put("url", url);
70
- out.put("count", count);
71
- out.put("error", error);
72
- out.put("time", time);
73
-
74
- out.id = "ip-url";
75
- out.time = now;
76
-
77
- DataPackSender.sendStatRemoteIpUrlPack(out);
78
- };
79
-
80
- StatRemoteIpurl.prototype.clear = function () {
81
- this.table.clear();
82
- };
83
-
84
- StatRemoteIpurl.prototype.size = function () {
85
- return this.table.size();
86
- };
87
-
88
- module.exports = new StatRemoteIpurl();