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,367 +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 os = require('os');
8
- var PackageCtrHelper = require('./packagectr-helper'),
9
- RequestQueue = require('../util/request-queue'),
10
- PackEnum = require('../pack/packenum'),
11
- ParamDef = require('../net/paramdef'),
12
- Configure = require('../conf/configure'),
13
- MapValue = require('../value/map-value'),
14
- DateUtil = require('../util/dateutil'),
15
- TextValue = require('../value/text-value'),
16
- ResourceProfile = require('../util/resourceprofile'),
17
- TraceContextManager = require('../trace/trace-context-manager'),
18
- Logger = require('../logger'),
19
- StatusDetector = require('../topology/status-detector'),
20
- BlobValue = require('../value/blob-value'),
21
- conf = require('../conf/configure');
22
-
23
- var ControlHandler = function () {
24
- this.queue = new RequestQueue(100);
25
- this._dataPackSender = null;
26
- }
27
-
28
- ControlHandler.prototype.add = function (p /* Pack */) {
29
- this.process(p);
30
- };
31
-
32
- ControlHandler.prototype.process = async function (p) {
33
- switch (p.getPackType()) {
34
- case PackEnum.PARAMETER:
35
- await this.handle(p);
36
- break;
37
- default:
38
- Logger.printError('WHATAP-203', 'Unknown pack received ' + p, new Error('Unknown pack'));
39
- }
40
- };
41
-
42
- ControlHandler.prototype.handle = async function (p) {
43
- var self = this;
44
- if (!this._dataPackSender) {
45
- this._dataPackSender = require('../data/datapack-sender');
46
- }
47
- switch (p.id) {
48
- case ParamDef.CONFIGURE_GET:
49
- var m = Configure.readCustomConfig();
50
- p.setMapValue(m);
51
- self._dataPackSender.sendResponseHide(p.getResponse());
52
- break;
53
- case ParamDef.GET_ACTIVE_STACK:
54
- break;
55
- case ParamDef.GET_ACTIVE_TRANSACTION_DETAIL:
56
- try {
57
- var threadId = p.getNumber("thread_id");
58
- var profile = p.getLong("profile");
59
- var m = getCurrentStackDetail(threadId, profile);
60
- p.putValue("detail", m);
61
-
62
- self._dataPackSender.sendResponseHide(p.getResponse());
63
- } catch (e) {
64
- Logger.printError('WHATAP-010', 'Active Transaction Detail', e, true);
65
- }
66
- break;
67
- case ParamDef.GET_ACTIVE_TRANSACTION_LIST:
68
- try {
69
- var m = getActiveTxList();
70
- p.putValue("active", m);
71
- self._dataPackSender.sendResponseHide(p.getResponse());
72
- } catch (e) {
73
- Logger.printError('WHATAP-203', 'Get active transaction list ', e, true);
74
- }
75
- break;
76
- case ParamDef.HEAP_HISTO:
77
-
78
- break;
79
- case ParamDef.LOADED_CLASS_LIST:
80
- try {
81
- var packageList = PackageCtrHelper.getLoadedPackageList();
82
- var mv = new MapValue();
83
- var indexLv = mv.newList("index");
84
- var nameLv = mv.newList("name");
85
- var typeLv = mv.newList("type");
86
- var superClassLv = mv.newList("superClass");
87
- var interfacesLv = mv.newList("interfaces");
88
- var resourceLv = mv.newList("resource");
89
-
90
- for (var i = 0; i < packageList.length; i++) {
91
- var pkg = packageList[i];
92
- indexLv.addLong(i);
93
- nameLv.addString(pkg);
94
- typeLv.addString(pkg);
95
- superClassLv.addString(pkg);
96
- interfacesLv.addString(pkg);
97
- resourceLv.addString(pkg);
98
- }
99
- p.putValue("classlist", mv);
100
- } catch (e) {
101
- p.put("error", e.toString());
102
- }
103
- self._dataPackSender.sendResponseHide(p.getResponse());
104
- break;
105
-
106
- case ParamDef.LOADED_CLASS_DETAIL:
107
- var pkgName = p.getText("classname");
108
- try {
109
- var dependencies = PackageCtrHelper.getPackageDetail(pkgName);
110
- var subPkgNameAndVersion = '';
111
- for (var k in dependencies) {
112
- var dep = dependencies[k];
113
- subPkgNameAndVersion += k + ": " + dep + "\n";
114
- }
115
- p.put("class", subPkgNameAndVersion);
116
- } catch (e) {
117
- p.put("error", e.toString());
118
- }
119
- break;
120
- case ParamDef.LOADED_CLASS_REDEFINE:
121
- self._dataPackSender.sendResponseHide(p.getResponse());
122
- break;
123
- case ParamDef.NODE_MODULE_DEPENDENCY:
124
-
125
- var mv = new MapValue();
126
- try {
127
- var dependencies = PackageCtrHelper.getDependencies();
128
- var keys = Object.keys(dependencies);
129
-
130
- for (var i = 0; i < keys.length; i++) {
131
- mv.putString(keys[i], JSON.stringify(dependencies[keys[i]]));
132
- }
133
- p.putValue("module", mv);
134
- } catch (e) {
135
- Logger.printError('WHATAP-003', 'Node Module Dependency ', e, true);
136
- }
137
- self._dataPackSender.sendResponseHide(p.getResponse());
138
- break;
139
- case ParamDef.GET_ENV:
140
- try {
141
- var mv = new MapValue();
142
- let ignore_env_variable = conf.getProperty('ignore_env_variable_set', '');
143
- let ignore_env_variable_set = ignore_env_variable ? new Set(ignore_env_variable.split(',').map(item => item.trim())) : new Set();
144
- for (var k in process.env) {
145
- if(ignore_env_variable_set.has(k)) {
146
- continue;
147
- }
148
- var v = process.env[k];
149
- mv.putString(k, v);
150
- }
151
- p.putValue("env", mv);
152
- } catch (e) {
153
- p.putValue("error", e.toString());
154
- }
155
- self._dataPackSender.sendResponseHide(p.getResponse());
156
- break;
157
-
158
- case ParamDef.SYSTEM_GC:
159
- try {
160
- var mem1 = process.memoryUsage();
161
- var total1 = mem1.heapTotal;
162
- var used1 = mem1.heapUsed;
163
-
164
- if (global && global.gc && typeof global.gc === 'function') {
165
- global.gc();
166
- } else {
167
- Logger.printError('WHATAP-177', 'Garbage collection unavailable. Pass --expose-gc '
168
- + 'when launching node to enable forced garbage collection.', new Error());
169
- }
170
-
171
- var mem2 = process.memoryUsage();
172
- var total2 = mem2.heapTotal;
173
- var used2 = mem2.heapUsed;
174
-
175
- var mv = new MapValue();
176
- mv.putLong("before-t", total1);
177
- mv.putLong("before-u", used1);
178
- mv.putLong("after-t", total2);
179
- mv.putLong("after-u", used2);
180
- p.putValue("gc", mv);
181
- } catch (e) {
182
- p.putValue("error", e.toString());
183
- }
184
- self._dataPackSender.sendResponseHide(p.getResponse());
185
- break;
186
- case ParamDef.SET_CONFIG:
187
- try {
188
- var mv = p.getValue('config');
189
- var en = mv.keys();
190
- var props = {};
191
- while(en.hasMoreElements()){
192
- var key = en.nextElement();
193
- var val = mv.getText(key);
194
- props[key] = val
195
- }
196
- Configure.saveProperty(props);
197
- } catch (e) {
198
- p.putValue("error", e.toString())
199
- }
200
- self._dataPackSender.sendResponseHide(p.getResponse());
201
- break;
202
-
203
- case ParamDef.LOADED_CLASS_DETAIL:
204
-
205
- break;
206
-
207
- case ParamDef.OPEN_SOCKET_LIST:
208
-
209
- break;
210
-
211
- case ParamDef.RESET_STRING_SENT_MARK:
212
- break;
213
- case ParamDef.AGENT_LOG_LIST:
214
- var o = Logger.getLogFiles();
215
- if (o !== null) {
216
- p.putValue("files", o);
217
- }
218
- self._dataPackSender.sendResponseHide(p.getResponse());
219
- break;
220
-
221
- case ParamDef.AGENT_LOG_READ:
222
- var file = p.getText("file");
223
- var endpos = p.getNumber("pos");
224
- var length = p.getNumber("length"); // 최대 16k 만 가능함...
225
- length = Math.min(length, 8000);
226
- if (endpos == 0) {
227
- endpos += length;
228
- }
229
- Logger.read(file, endpos, length, function (before, next, text) {
230
- p.putLong("before", before);
231
- p.putLong("next", next);
232
- p.putString("text", text);
233
- self._dataPackSender.sendResponseHide(p.getResponse());
234
- });
235
- break;
236
- case ParamDef.GET_TOPOLOGY:
237
- try {
238
- const node = await new StatusDetector().process();
239
- if (node) {
240
- p.putValue("node", new BlobValue(node.toBytes()));
241
- }
242
- this._dataPackSender.sendResponseHide(p.getResponse());
243
- } catch (e) {
244
- Logger.printError('WHATAP-203', 'Node Module Dependency ', e, true);
245
- }
246
- break;
247
- }
248
- }
249
-
250
- function getActiveTxList() {
251
- var out = new MapValue()
252
- var time = out.newList("time");
253
- var tx_hash = out.newList("tx_hash");
254
- var tx_name = out.newList("tx_name");
255
- var profile = out.newList("profile");
256
- var ip = out.newList("ip");
257
-
258
- var userid = out.newList("userid");
259
- var elapsed = out.newList("elapsed");
260
- var cputime = out.newList("cputime");
261
- var malloc = out.newList("malloc");
262
- var sqlCount = out.newList("sqlCount");
263
-
264
- var sqlTime = out.newList("sqlTime");
265
- var httpcCount = out.newList("httpcCount");
266
- var httpcTime = out.newList("httpcTime");
267
- var threadId = out.newList("threadId");
268
- var threadStat = out.newList("threadStat");
269
-
270
- var act_dbc = out.newList("act_dbc");
271
- var act_sql = out.newList("act_sql");
272
- var act_httpc = out.newList("act_httpc");
273
-
274
-
275
- var currentTime = DateUtil.currentTime();
276
-
277
- //여기서 초기화가 안된 상태인경우가 있음..
278
- TraceContextManager = require('../trace/trace-context-manager');
279
- var en = TraceContextManager.getContextEnumeration();
280
-
281
- while (en.hasMoreElements()) {
282
- var ctx = en.nextElement();
283
- if (ctx == null)
284
- continue;
285
-
286
- time.addLong(currentTime);
287
- tx_hash.addLong(ctx.service_hash);
288
- tx_name.addString(ctx.service_name);
289
- profile.addLong(ctx.txid);
290
- ip.addLong(ctx.remoteIp);
291
- userid.addLong(ctx.userid);
292
- elapsed.addLong(ctx.getElapsedTime());
293
- cputime.addLong(ResourceProfile.getCPUTime() - ctx.start_cpu);
294
- var m = ResourceProfile.getUsedHeapSize() - ctx.start_malloc;
295
- malloc.addLong(m < 0 ? 0 : m);
296
- sqlCount.addLong(ctx.sql_count);
297
- sqlTime.addLong(ctx.sql_time);
298
- httpcCount.addLong(ctx.httpc_count);
299
- httpcTime.addLong(ctx.httpc_time);
300
- threadId.addLong(ctx._id);
301
- threadStat.addLong(0);
302
-
303
- act_dbc.addLong(ctx.active_dbc);
304
- act_sql.addLong(ctx.active_sqlhash);
305
-
306
- act_httpc.addLong(ctx.active_httpc_hash);
307
- }
308
- return out;
309
- }
310
-
311
- function getCurrentStackDetail(traceId, txid) {
312
- var out = new MapValue();
313
-
314
- var ctx = TraceContextManager.getContext(traceId);
315
- if (ctx != null && ctx.txid.equals(txid)) {
316
- out.putLong("time", DateUtil.currentTime());
317
- out.putLong("tx_hash", ctx.service_hash);
318
- out.putString("tx_name", ctx.service_name);
319
- out.putLong("profile", ctx.txid);
320
- out.putLong("ip", ctx.remoteIp);
321
- out.putLong("userid", ctx.userToken);
322
- out.putLong("elapsed", ctx.getElapsedTime());
323
- out.putLong("sqlCount", ctx.sql_count);
324
- out.putLong("sqlTime", ctx.sql_time);
325
- out.putLong("httpcCount", ctx.httpc_count);
326
- out.putLong("httpcTime", ctx.httpc_time);
327
- out.putLong("threadId", ctx.thread_id);
328
-
329
- ///////////////////
330
- if (ctx.http_content_type != null) {
331
- out.putString("httpContentType", ctx.http_content_type);
332
- }
333
- ///////////////////
334
-
335
- if (ctx.active_sqlhash != 0) {
336
- out.putLong("act_dbc", ctx.active_dbc);
337
- out.putLong("act_sql", ctx.active_sqlhash);
338
- }
339
- if (ctx.active_httpc_hash != 0) {
340
- out.putLong("act_httpc", ctx.active_httpc_hash);
341
- out.putLong("act_httpc_host", ctx.httpc_host);
342
- out.putLong("act_httpc_port", ctx.httpc_port);
343
- }
344
- out.putString("method", ctx.http_method);
345
-
346
- if (ctx.mtid.isZero() === false) {
347
- out.putLong("mtid", ctx.mtid);
348
- out.putLong("mdepth", ctx.mdepth);
349
- out.putLong("mcaller", ctx.mcaller_txid);
350
- }
351
-
352
- // var se = ctx.stack;
353
- // var stack = out.newList("callstack");
354
- // for (var i = 0; i < se.length; i++) {
355
- // stack.addString(se[i]);
356
- // }
357
-
358
- var stack = out.newList("callstack");
359
- stack.addString("Last step time: " + new Date(ctx.last_footprint_time).toString());
360
- stack.addString("Last step to now: " +(Date.now() - ctx.last_footprint_time) +" ms");
361
- stack.addString("Last step message: " + ctx.last_footprint_desc);
362
-
363
-
364
- }
365
- return out;
366
- }
367
- module.exports = new ControlHandler();
@@ -1,27 +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
- const http = require('http');
9
- var keepAliveAgent = new http.Agent({ keepAlive: true });
10
-
11
-
12
- var baseConfig = {
13
- keepAlive: true,
14
- keepAliveTimeoutMsecs: 500,
15
- maxSockets: 1 // requests are serialized
16
- }
17
-
18
- baseConfig.agent = keepAliveAgent;
19
-
20
-
21
- http.request(baseConfig, onResponseCallback);
22
-
23
-
24
-
25
- var RequestAgent = function(){
26
-
27
- }
@@ -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 conf = require('../../conf/configure'),
8
- IntIntMap = require('../../util/intint-map'),
9
- secuMaster = require('../../net/security-master'),
10
- LinkedMap = require('../../util/linkedmap');
11
-
12
-
13
- function MeterActiveX() {
14
- this.statByOid = new IntIntMap().setMax(2001);
15
- this.statByGroup = createLinkedMap();
16
- this.stat_sql = new IntIntMap().setMax(301);
17
- this.stat_httpc = new IntIntMap().setMax(301);
18
- this.unknown = 0;
19
- }
20
-
21
- MeterActiveX.prototype.addTx = function (caller_pcode, caller_okind, caller_oid) {
22
- if (caller_oid) {
23
- this.statByGroup.add({pcode:caller_pcode, okind:caller_okind}, 1);
24
- if (caller_pcode == secuMaster.PCODE) {
25
- this.statByOid.add(caller_oid, 1);
26
- }
27
- } else {
28
- this.unknown++;
29
- }
30
-
31
- };
32
- MeterActiveX.prototype.addSql = function (dbc) {
33
- this.stat_sql.add(dbc, 1);
34
- };
35
-
36
- MeterActiveX.prototype.addHttpc = function (host) {
37
- this.stat_httpc.add(host, 1);
38
- };
39
-
40
- MeterActiveX.prototype.reinit = function () {
41
- this.statByOid = new IntIntMap().setMax(2001);
42
- this.statByGroup = createLinkedMap();
43
- this.stat_sql = new IntIntMap().setMax(301);
44
- this.stat_httpc = new IntIntMap().setMax(301);
45
- this.unknown = 0;
46
- };
47
-
48
-
49
- function createLinkedMap() {
50
- var m = new LinkedMap(1009, 1).setMax(307);
51
- m.hash = function (k) {
52
- if (k._hash_) {
53
- return k._hash_;
54
- }
55
- var result = 1;
56
- result = 31 * result + k.pcode;
57
- result = 31 * result + k.okind;
58
-
59
- k._hash_ = result;
60
- return result;
61
- };
62
- m.equals = function (k1, k2) {
63
- return k1.pcode === k2.pcode && k1.okind === k2.okind;
64
- };
65
- return m;
66
- }
67
- module.exports = new MeterActiveX();
@@ -1,57 +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 IntKeyLinkedMap = require('../../util/intkey-linkedmap');
8
- var Long = require('long');
9
- var Logger = require('../../logger');
10
- var conf = require('../../conf/configure');
11
-
12
- function Bucket() {
13
- this.count = 0;
14
- this.time =0;
15
- this.error = 0;
16
- }
17
-
18
- function MeterHttpC() {
19
- this.bucket = new Bucket();
20
- this.stat = new IntKeyLinkedMap(309, 1).setMax(307);
21
- this.stat.create = function (key) {
22
- return new Bucket();
23
- };
24
- }
25
-
26
- MeterHttpC.prototype.add = function (host,elapsed, err) {
27
- try {
28
- var b = this.bucket;
29
- b.count++;
30
- b.time += elapsed;
31
- if(err) {
32
- b.error++;
33
- }
34
-
35
- if (conf.httpc_host_meter_enabled && host != 0) {
36
- b = this.stat.intern(host);
37
- b.count++;
38
- b.time += elapsed;
39
- if (err) {
40
- b.error++;
41
- }
42
- }
43
- } catch(e) {
44
- Logger.printError("WHATAP-608", "MeterHttpC Error", e);
45
- }
46
- };
47
- MeterHttpC.prototype.getBucketReset = function () {
48
- var b = this.bucket;
49
- this.bucket = new Bucket();
50
- return b;
51
- };
52
- MeterHttpC.prototype.resetStat = function () {
53
- if(this.stat.size() > 0){
54
- this.stat.clear();
55
- }
56
- }
57
- module.exports = new MeterHttpC();
@@ -1,9 +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
- function MeterResource() {
8
-
9
- };
@@ -1,168 +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 HitMapPack1 = require('../../pack/hitmap-pack1'),
8
- IntKeyMap = require('../../util/intkey-map'),
9
- SecurityMaster = require('../../net/security-master'),
10
- conf = require('../../conf/configure'),
11
- secu = require('../../net/security-master'),
12
- IntKeyLinkedMap = require('../../util/intkey-linkedmap'),
13
- LinkedMap = require('../../util/linkedmap'),
14
- Logger = require('../../logger'),
15
- EventLevel = require('../../data/event-level');
16
- Long = require('long');
17
-
18
- function Bucket () {
19
- this.hitmap = new HitMapPack1();
20
- this.count = 0;
21
- this.timesum = 0;
22
- this.error = 0;
23
- this.count_satisfied = 0;
24
- this.count_tolerated = 0;
25
-
26
- this.reset = function () {
27
- this.count = 0;
28
- this.timesum = 0;
29
- this.error = 0;
30
- this.count_satisfied = 0;
31
- this.count_tolerated = 0;
32
- this.hitmap = new HitMapPack1();
33
- };
34
- }
35
- function BucketSimple () {
36
- this.count = 0;
37
- this.timesum = 0;
38
- this.error = 0;
39
- this.count_satisfied = 0;
40
- this.count_tolerated = 0;
41
-
42
- this.reset = function () {
43
- this.count = 0;
44
- this.timesum =0;
45
- this.error = 0;
46
- this.count_satisfied = 0;
47
- this.count_tolerated = 0;
48
- };
49
- }
50
-
51
- function MeterService() {
52
- if(typeof MeterService.instance === 'object') {
53
- return MeterService.instance;
54
- }
55
- this.bucket = new Bucket();
56
- this.unknown = new BucketSimple();
57
- this.stat = new IntKeyLinkedMap(309, 1).setMax(307);
58
- this.stat.create = function (key) {
59
- return new BucketSimple();
60
- };
61
- this.statByGroup = new LinkedMap(309, 1).setMax(307);
62
- this.statByGroup.create = function (key) {
63
- return new BucketSimple();
64
- };
65
- this.statByGroup.hash = function (k) {
66
- if(k._hash_){
67
- return k._hash_;
68
- }
69
- var result = 1;
70
- result = 31 * result + k.pcode;
71
- result = 31 * result + k.okind;
72
-
73
- k._hash_=result;
74
- return result;
75
- };
76
- this.statByGroup.equals = function (k1,k2) {
77
- return k1.pcode === k2.pcode && k1.okind === k2.okind;
78
- };
79
-
80
- MeterService.instance = this;
81
- }
82
-
83
- MeterService.prototype.add = function (serviceHash, elapsed, errorLevel, caller_pcode, caller_okind, caller_oid , apdex) {
84
- if(elapsed < 0) {
85
- elapsed = 0;
86
- }
87
-
88
- var b = this.bucket;
89
- b.count += 1;
90
- b.timesum +=elapsed;
91
-
92
- var err = errorLevel >= EventLevel.WARNING;
93
- if (err) {
94
- b.error += 1;
95
- } else {
96
- if (elapsed <= conf.apdex_time_t) {
97
- b.count_satisfied += 1;
98
- apdex=2;
99
- } else if (elapsed <= conf.apdex_time_4t) {
100
- b.count_tolerated += 1;
101
- apdex=1;
102
- }
103
- }
104
- b.hitmap.add(elapsed, err);
105
-
106
- if (conf.tx_caller_meter_enabled) {
107
- try{
108
- var b1 = null;
109
- if( caller_oid) {
110
- if (caller_pcode == SecurityMaster.PCODE) {
111
- b1 = this.stat.intern(caller_oid);
112
- b1.count++;
113
- b1.timesum += elapsed;
114
- if (err) {
115
- b1.error++;
116
- }
117
- }
118
-
119
- b1 = this.statByGroup.intern({pcode:caller_pcode, okind:caller_okind});
120
- b1.count++;
121
- b1.timesum += elapsed;
122
- if (err) {
123
- b1.error++;
124
- }
125
- }else {
126
- b1 = this.unknown;
127
- b1.count++;
128
- b1.timesum += elapsed;
129
- if (err) {
130
- b1.error++;
131
- }
132
- }
133
- }catch(e){
134
- Logger.printError('WHATAP-080', 'Meter Service add ', e, true);
135
- }
136
- }
137
- };
138
- MeterService.prototype.getBucket = function () {
139
- return this.bucket;
140
- };
141
- MeterService.prototype.resetStat = function () {
142
- if(this.stat.size() > 0){
143
- this.stat.clear();
144
- }
145
- if(this.statByGroup.size() > 0){
146
- this.statByGroup.clear();
147
- }
148
- if (this.unknown.count > 0) {
149
- this.unknown = new Bucket();
150
- }
151
- };
152
-
153
- function TopService(hash) {
154
- this.hash = hash | 0;
155
- this.count = 0;
156
- this.error = 0;
157
- this.time = 0;
158
-
159
- this.clear = function () {
160
- this.count = 0;
161
- this.error = 0;
162
- this.time = 0;
163
- };
164
- };
165
-
166
- module.exports.MeterService = new MeterService();
167
- module.exports.Bucket = Bucket;
168
- module.exports.TopService = TopService;