whatap 0.4.78 → 0.4.80

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 (216) hide show
  1. package/.vscode/keep-context.json +3 -3
  2. package/README.md +51 -51
  3. package/bindings/darwin/x64/whatap.node +0 -0
  4. package/bindings/linux/ia32/whatap.node +0 -0
  5. package/bindings/linux/x64/whatap.node +0 -0
  6. package/help.txt +10 -10
  7. package/index.js +8 -8
  8. package/lib/conf/conf-sys-mon.js +100 -100
  9. package/lib/conf/config-default.js +238 -238
  10. package/lib/conf/configure.js +423 -423
  11. package/lib/conf/license.js +41 -41
  12. package/lib/control/cmd-config.js +23 -23
  13. package/lib/control/control-handler.js +344 -344
  14. package/lib/control/packagectr-helper.js +149 -149
  15. package/lib/core/agent.js +329 -328
  16. package/lib/core/interceptor.js +142 -142
  17. package/lib/core/request-agent.js +26 -26
  18. package/lib/counter/counter-manager.js +127 -127
  19. package/lib/counter/meter/meter-activex.js +66 -66
  20. package/lib/counter/meter/meter-httpc.js +57 -57
  21. package/lib/counter/meter/meter-resource.js +9 -9
  22. package/lib/counter/meter/meter-service.js +167 -167
  23. package/lib/counter/meter/meter-socket.io.js +50 -50
  24. package/lib/counter/meter/meter-sql.js +70 -70
  25. package/lib/counter/meter/meter-users.js +57 -57
  26. package/lib/counter/meter.js +183 -183
  27. package/lib/counter/task/activetransaction.js +93 -93
  28. package/lib/counter/task/agentinfo.js +105 -105
  29. package/lib/counter/task/counter-task.js +9 -9
  30. package/lib/counter/task/gcstat.js +34 -34
  31. package/lib/counter/task/heapmem.js +24 -24
  32. package/lib/counter/task/httpc.js +75 -75
  33. package/lib/counter/task/proc-cpu.js +28 -28
  34. package/lib/counter/task/realtimeuser.js +30 -30
  35. package/lib/counter/task/res/systemECSTask.js +54 -54
  36. package/lib/counter/task/res/systemKubeTask.js +52 -52
  37. package/lib/counter/task/res/util/awsEcsClientThread.js +166 -166
  38. package/lib/counter/task/res/util/linuxProcStatUtil.js +13 -13
  39. package/lib/counter/task/res-sys-cpu.js +61 -61
  40. package/lib/counter/task/service.js +201 -201
  41. package/lib/counter/task/socketio.js +29 -29
  42. package/lib/counter/task/sql.js +104 -104
  43. package/lib/counter/task/systemperf.js +42 -42
  44. package/lib/data/datapack-sender.js +256 -256
  45. package/lib/data/dataprofile-agent.js +136 -136
  46. package/lib/data/datatext-agent.js +135 -135
  47. package/lib/data/event-level.js +15 -15
  48. package/lib/data/test.js +48 -48
  49. package/lib/env/constants.js +20 -20
  50. package/lib/kube/kube-client.js +143 -143
  51. package/lib/lang/text-types.js +58 -58
  52. package/lib/logger.js +319 -319
  53. package/lib/net/netflag.js +54 -54
  54. package/lib/net/paramdef.js +40 -40
  55. package/lib/net/receiver.js +65 -65
  56. package/lib/net/security-master.js +182 -173
  57. package/lib/net/sender.js +140 -140
  58. package/lib/net/tcp-return.js +17 -17
  59. package/lib/net/tcp-session.js +285 -285
  60. package/lib/net/tcpreq-client-proxy.js +69 -69
  61. package/lib/net/tcprequest-mgr.js +57 -57
  62. package/lib/observers/cluster-observer.js +21 -21
  63. package/lib/observers/express-observer.js +214 -214
  64. package/lib/observers/file-observer.js +184 -184
  65. package/lib/observers/global-observer.js +30 -30
  66. package/lib/observers/http-observer.js +704 -704
  67. package/lib/observers/maria-observer.js +382 -382
  68. package/lib/observers/memcached-observer.js +55 -55
  69. package/lib/observers/mongo-observer.js +262 -265
  70. package/lib/observers/mongodb-observer.js +197 -197
  71. package/lib/observers/mongoose-observer.js +83 -83
  72. package/lib/observers/mssql-observer.js +205 -205
  73. package/lib/observers/mysql-observer.js +436 -394
  74. package/lib/observers/net-observer.js +72 -72
  75. package/lib/observers/pgsql-observer.js +295 -295
  76. package/lib/observers/process-observer.js +25 -25
  77. package/lib/observers/promise-observer.js +31 -31
  78. package/lib/observers/redis-observer.js +156 -109
  79. package/lib/observers/schedule-observer.js +66 -66
  80. package/lib/observers/socket.io-observer.js +54 -54
  81. package/lib/observers/stream-observer.js +19 -19
  82. package/lib/observers/thrift-observer.js +196 -196
  83. package/lib/pack/activestack-pack.js +54 -54
  84. package/lib/pack/counter-pack.js +649 -649
  85. package/lib/pack/errorsnap-pack.js +68 -68
  86. package/lib/pack/event-pack.js +53 -53
  87. package/lib/pack/hitmap-pack.js +62 -62
  88. package/lib/pack/hitmap-pack1.js +146 -146
  89. package/lib/pack/netstat.js +14 -14
  90. package/lib/pack/pack.js +49 -49
  91. package/lib/pack/packenum.js +60 -60
  92. package/lib/pack/param-pack.js +213 -213
  93. package/lib/pack/profile-pack.js +48 -48
  94. package/lib/pack/realtimeuser-pack.js +40 -40
  95. package/lib/pack/stat-general-pack.js +95 -95
  96. package/lib/pack/staterror-pack.js +119 -119
  97. package/lib/pack/stathttpc-pack.js +66 -66
  98. package/lib/pack/stathttpc-rec.js +78 -78
  99. package/lib/pack/statremote-pack.js +45 -45
  100. package/lib/pack/statservice-pack.js +62 -62
  101. package/lib/pack/statservice-pack1.js +87 -87
  102. package/lib/pack/statservice-rec.js +292 -292
  103. package/lib/pack/statservice-rec_dep.js +151 -151
  104. package/lib/pack/statsql-pack.js +69 -69
  105. package/lib/pack/statsql-rec.js +100 -100
  106. package/lib/pack/statuseragent-pack.js +43 -43
  107. package/lib/pack/tagcount-pack.js +398 -398
  108. package/lib/pack/tagctr.js +14 -14
  109. package/lib/pack/text-pack.js +49 -49
  110. package/lib/pack/time-count.js +25 -25
  111. package/lib/pack/websocket.js +14 -14
  112. package/lib/plugin/plugin-loadermanager.js +56 -56
  113. package/lib/plugin/plugin.js +75 -75
  114. package/lib/requestlog.js +326 -326
  115. package/lib/service/tx-record.js +288 -284
  116. package/lib/stat/stat-error.js +116 -116
  117. package/lib/stat/stat-httpc.js +97 -97
  118. package/lib/stat/stat-remoteip.js +46 -46
  119. package/lib/stat/stat-sql.js +112 -112
  120. package/lib/stat/stat-tranx.js +57 -57
  121. package/lib/stat/stat-tx-caller.js +159 -159
  122. package/lib/stat/stat-tx-domain.js +110 -110
  123. package/lib/stat/stat-tx-referer.js +111 -111
  124. package/lib/stat/stat-useragent.js +48 -48
  125. package/lib/stat/timingsender.js +72 -72
  126. package/lib/step/activestack-step.js +37 -37
  127. package/lib/step/dbc-step.js +35 -35
  128. package/lib/step/http-stepx.js +66 -66
  129. package/lib/step/message-step.js +39 -39
  130. package/lib/step/method-stepx.js +46 -46
  131. package/lib/step/resultset-step.js +39 -39
  132. package/lib/step/securemsg-step.js +43 -43
  133. package/lib/step/socket-step.js +46 -46
  134. package/lib/step/sql-stepx.js +67 -67
  135. package/lib/step/sqlxtype.js +15 -15
  136. package/lib/step/step.js +65 -65
  137. package/lib/step/stepenum.js +53 -53
  138. package/lib/trace/local-context.js +13 -13
  139. package/lib/trace/parsed-sql.js +13 -13
  140. package/lib/trace/profile-collector.js +70 -70
  141. package/lib/trace/serviceurl-pattern-detector.js +117 -117
  142. package/lib/trace/trace-context-manager.js +195 -195
  143. package/lib/trace/trace-context.js +134 -134
  144. package/lib/util/anylist.js +102 -102
  145. package/lib/util/array-util.js +100 -100
  146. package/lib/util/bitutil.js +27 -27
  147. package/lib/util/cardinality/hyperloglog.js +105 -105
  148. package/lib/util/cardinality/murmurhash.js +31 -31
  149. package/lib/util/cardinality/registerset.js +74 -74
  150. package/lib/util/config-util.js +17 -17
  151. package/lib/util/cypher.js +89 -89
  152. package/lib/util/datetimehelper.js +237 -229
  153. package/lib/util/dateutil.js +110 -106
  154. package/lib/util/errordata.js +20 -20
  155. package/lib/util/escape-literal-sql.js +342 -342
  156. package/lib/util/hashutil2.js +126 -126
  157. package/lib/util/hexa32.js +57 -57
  158. package/lib/util/index.js +78 -78
  159. package/lib/util/intint-map.js +47 -47
  160. package/lib/util/intkey-linkedmap.js +26 -26
  161. package/lib/util/intkey-map.js +25 -25
  162. package/lib/util/intset.js +82 -82
  163. package/lib/util/iputil.js +119 -119
  164. package/lib/util/iputil_x.js +526 -526
  165. package/lib/util/keygen.js +17 -17
  166. package/lib/util/kube-util.js +72 -72
  167. package/lib/util/longint-linkedmap.js +35 -35
  168. package/lib/util/longkey-linkedmap.js +25 -25
  169. package/lib/util/longlong-linkedmap.js +37 -37
  170. package/lib/util/nodeutil.js +67 -67
  171. package/lib/util/oidutil.js +96 -93
  172. package/lib/util/paramsecurity.js +78 -78
  173. package/lib/util/pathtree.js +172 -172
  174. package/lib/util/pre-process.js +13 -13
  175. package/lib/util/process-seq.js +165 -165
  176. package/lib/util/property-util.js +35 -35
  177. package/lib/util/request-queue.js +42 -42
  178. package/lib/util/requestdouble-queue.js +72 -72
  179. package/lib/util/resourceprofile.js +156 -156
  180. package/lib/util/seedrandom.js +242 -242
  181. package/lib/util/stop-watch.js +29 -29
  182. package/lib/util/string-util.js +9 -9
  183. package/lib/util/stringkey-linkedmap.js +28 -28
  184. package/lib/util/stringnum-linkedmap.js +31 -31
  185. package/lib/util/stringset.js +65 -65
  186. package/lib/util/system-util.js +9 -9
  187. package/lib/util/userid-util.js +57 -57
  188. package/lib/util/utils.js +67 -67
  189. package/lib/value/blob-value.js +61 -61
  190. package/lib/value/boolean-value.js +51 -51
  191. package/lib/value/decimal-value.js +71 -71
  192. package/lib/value/double-summary.js +105 -105
  193. package/lib/value/double-value.js +50 -50
  194. package/lib/value/float-array.js +59 -59
  195. package/lib/value/float-value.js +64 -64
  196. package/lib/value/int-array.js +59 -59
  197. package/lib/value/int-map-value.js +151 -151
  198. package/lib/value/int-value.js +64 -64
  199. package/lib/value/ip4-value.js +83 -83
  200. package/lib/value/list-value.js +136 -136
  201. package/lib/value/long-array.js +59 -59
  202. package/lib/value/long-summary.js +105 -105
  203. package/lib/value/map-value.js +175 -175
  204. package/lib/value/metric-value.js +157 -157
  205. package/lib/value/null-value.js +42 -42
  206. package/lib/value/number-value.js +34 -34
  207. package/lib/value/summary-value.js +29 -29
  208. package/lib/value/text-array.js +117 -117
  209. package/lib/value/text-value.js +59 -59
  210. package/lib/value/texthash-value.js +49 -49
  211. package/lib/value/value.js +14 -14
  212. package/lib/value/valueenum.js +99 -99
  213. package/logs/whatap-20230906.log +54 -0
  214. package/package.json +28 -28
  215. package/whatap.conf +1 -1
  216. package/logs/whatap-20230616.log +0 -13
@@ -1,113 +1,113 @@
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
- const TABLE_MAX_SIZE = 5000;
8
-
9
- var LinkedMap = require('../util/linkedmap'),
10
- SqlRec = require('../pack/statsql-rec'),
11
- StatSqlPack = require('../pack/statsql-pack'),
12
- DataPackSender = require('../data/datapack-sender');
13
-
14
- function StatSql() {
15
- if(typeof StatSql.instance === 'object') {
16
- return StatSql.instance;
17
- }
18
-
19
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
20
- this.table.hash = function (k) {
21
- if(k._hash_){
22
- return k._hash_;
23
- }
24
- var result = 1;
25
- result = 31 * result + k.dbc;
26
- result = 31 * result + k.sql;
27
-
28
- k._hash_=result;
29
- return result;
30
- }
31
- this.table.equals = function (k1,k2) {
32
- return k1.dbc === k2.dbc && k1.sql === k2.sql;
33
- }
34
- this.table.create = function (key) {
35
- if(this.isFull()) {
36
- return null;
37
- }
38
- var rec = new SqlRec();
39
- rec.dbc = key.dbc;
40
- rec.sql = key.sql;
41
- rec.time_min = Number.MAX_SAFE_INTEGER;
42
- return rec;
43
- };
44
-
45
- StatSql.instance = this;
46
- }
47
- StatSql.prototype.getSql = function (dbc, sql) {
48
- var key = {dbc: dbc ,
49
- sql: sql
50
- };
51
- return this.table.intern(key);
52
- };
53
- StatSql.prototype.addFetch = function (dbc, sql, fetch, fetchTime) {
54
- if(sql === 0) {
55
- return;
56
- }
57
- var r = this.getSql(dbc, sql);
58
- if(r != null) {
59
- r.fetch_count += fetch;
60
- r.fetch_time += fetchTime;
61
- }
62
- };
63
- // StatSql.prototype.addUpdate = function (dbc, sql, updated) {
64
- // if(sql === 0) {
65
- // return;
66
- // }
67
- // var r = this.getSql(dbc, sql);
68
- // if(r != null) {
69
- // r.update_count = r.update_count.add(updated);
70
- // }
71
- // };
72
-
73
- StatSql.prototype.addSqlTime = function (urlHash, dbc, sql, time, isErr, updated) {
74
-
75
- urlHash = urlHash || 0;
76
- sql = sql || 0;
77
- time = time || 0;
78
- updated = updated || 0;
79
-
80
- if(sql === 0) {
81
- return;
82
- }
83
- var sqlRec = this.getSql(dbc, sql);
84
- if(sqlRec != null) {
85
- sqlRec.count_total++;
86
- sqlRec.time_sum +=time;
87
- sqlRec.time_std += time*time;
88
- sqlRec.time_min = Math.min(sqlRec.time_min, time);
89
- sqlRec.time_max = Math.max(sqlRec.time_max, time);
90
- if(isErr) {
91
- sqlRec.count_error++;
92
- }
93
- sqlRec.update_count +=updated;
94
- sqlRec.service = urlHash;
95
- }
96
- };
97
- StatSql.prototype.send = function (now) {
98
- if(this.table.size() === 0) {
99
- return;
100
- }
101
-
102
- var p = new StatSqlPack().setRecords(this.table.size(), this.table.values());
103
- p.time = now;
104
- this.table.clear();
105
- DataPackSender.sendStatSqlPack(p);
106
- };
107
- StatSql.prototype.clear = function () {
108
- this.table.clear();
109
- };
110
-
111
-
112
- //싱글톤으로 동작해야한다.
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
+ const TABLE_MAX_SIZE = 5000;
8
+
9
+ var LinkedMap = require('../util/linkedmap'),
10
+ SqlRec = require('../pack/statsql-rec'),
11
+ StatSqlPack = require('../pack/statsql-pack'),
12
+ DataPackSender = require('../data/datapack-sender');
13
+
14
+ function StatSql() {
15
+ if(typeof StatSql.instance === 'object') {
16
+ return StatSql.instance;
17
+ }
18
+
19
+ this.table = new LinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
20
+ this.table.hash = function (k) {
21
+ if(k._hash_){
22
+ return k._hash_;
23
+ }
24
+ var result = 1;
25
+ result = 31 * result + k.dbc;
26
+ result = 31 * result + k.sql;
27
+
28
+ k._hash_=result;
29
+ return result;
30
+ }
31
+ this.table.equals = function (k1,k2) {
32
+ return k1.dbc === k2.dbc && k1.sql === k2.sql;
33
+ }
34
+ this.table.create = function (key) {
35
+ if(this.isFull()) {
36
+ return null;
37
+ }
38
+ var rec = new SqlRec();
39
+ rec.dbc = key.dbc;
40
+ rec.sql = key.sql;
41
+ rec.time_min = Number.MAX_SAFE_INTEGER;
42
+ return rec;
43
+ };
44
+
45
+ StatSql.instance = this;
46
+ }
47
+ StatSql.prototype.getSql = function (dbc, sql) {
48
+ var key = {dbc: dbc ,
49
+ sql: sql
50
+ };
51
+ return this.table.intern(key);
52
+ };
53
+ StatSql.prototype.addFetch = function (dbc, sql, fetch, fetchTime) {
54
+ if(sql === 0) {
55
+ return;
56
+ }
57
+ var r = this.getSql(dbc, sql);
58
+ if(r != null) {
59
+ r.fetch_count += fetch;
60
+ r.fetch_time += fetchTime;
61
+ }
62
+ };
63
+ // StatSql.prototype.addUpdate = function (dbc, sql, updated) {
64
+ // if(sql === 0) {
65
+ // return;
66
+ // }
67
+ // var r = this.getSql(dbc, sql);
68
+ // if(r != null) {
69
+ // r.update_count = r.update_count.add(updated);
70
+ // }
71
+ // };
72
+
73
+ StatSql.prototype.addSqlTime = function (urlHash, dbc, sql, time, isErr, updated) {
74
+
75
+ urlHash = urlHash || 0;
76
+ sql = sql || 0;
77
+ time = time || 0;
78
+ updated = updated || 0;
79
+
80
+ if(sql === 0) {
81
+ return;
82
+ }
83
+ var sqlRec = this.getSql(dbc, sql);
84
+ if(sqlRec != null) {
85
+ sqlRec.count_total++;
86
+ sqlRec.time_sum +=time;
87
+ sqlRec.time_std += time*time;
88
+ sqlRec.time_min = Math.min(sqlRec.time_min, time);
89
+ sqlRec.time_max = Math.max(sqlRec.time_max, time);
90
+ if(isErr) {
91
+ sqlRec.count_error++;
92
+ }
93
+ sqlRec.update_count +=updated;
94
+ sqlRec.service = urlHash;
95
+ }
96
+ };
97
+ StatSql.prototype.send = function (now) {
98
+ if(this.table.size() === 0) {
99
+ return;
100
+ }
101
+
102
+ var p = new StatSqlPack().setRecords(this.table.size(), this.table.values());
103
+ p.time = now;
104
+ this.table.clear();
105
+ DataPackSender.sendStatSqlPack(p);
106
+ };
107
+ StatSql.prototype.clear = function () {
108
+ this.table.clear();
109
+ };
110
+
111
+
112
+ //싱글톤으로 동작해야한다.
113
113
  module.exports = new StatSql();
@@ -1,58 +1,58 @@
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
- TransactionRec = require('../pack/statservice-rec'),
9
- StatServicePack = require('../pack/statservice-pack'),
10
- StatServicePack1 = require('../pack/statservice-pack1'),
11
- conf = require('./../conf/configure'),
12
- Logger = require('../logger'),
13
- DataPackSender = require('../data/datapack-sender')
14
-
15
- const TABLE_MAX_SIZE = 5000;
16
-
17
- function StatTranx() {
18
- if(typeof StatTranx.instance === 'object') {
19
- return StatTranx.instance;
20
- }
21
-
22
- this.table = new IntKeyLinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
23
- this.table.create = function (hash) {
24
- if(this.isFull()) {
25
- return null;
26
- }
27
- var rec = new TransactionRec();
28
- rec.setUrlHash(hash);
29
- rec.time_min = Number.MAX_VALUE;
30
- return rec;
31
- };
32
-
33
- StatTranx.instance = this;
34
- }
35
-
36
- StatTranx.prototype.getService = function (hash) {
37
- return this.table.intern(hash);
38
- };
39
- StatTranx.prototype.send = function (now) {
40
- if(this.table.size() === 0) {
41
- return;
42
- }
43
- var p = undefined;
44
- if(conf.stat_service1_enabled){
45
- p = new StatServicePack1().setRecords(this.table.size(), this.table.values());
46
- p.spec = conf.mtrace_spec_hash;
47
- }else{
48
- p = new StatServicePack().setRecords(this.table.size(), this.table.values());
49
- }
50
- p.time = now;
51
- this.table.clear();
52
- DataPackSender.sendStatServicePack(p);
53
- };
54
- StatTranx.prototype.clear = function () {
55
- this.table.clear();
56
- };
57
-
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
+ TransactionRec = require('../pack/statservice-rec'),
9
+ StatServicePack = require('../pack/statservice-pack'),
10
+ StatServicePack1 = require('../pack/statservice-pack1'),
11
+ conf = require('./../conf/configure'),
12
+ Logger = require('../logger'),
13
+ DataPackSender = require('../data/datapack-sender')
14
+
15
+ const TABLE_MAX_SIZE = 5000;
16
+
17
+ function StatTranx() {
18
+ if(typeof StatTranx.instance === 'object') {
19
+ return StatTranx.instance;
20
+ }
21
+
22
+ this.table = new IntKeyLinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
23
+ this.table.create = function (hash) {
24
+ if(this.isFull()) {
25
+ return null;
26
+ }
27
+ var rec = new TransactionRec();
28
+ rec.setUrlHash(hash);
29
+ rec.time_min = Number.MAX_VALUE;
30
+ return rec;
31
+ };
32
+
33
+ StatTranx.instance = this;
34
+ }
35
+
36
+ StatTranx.prototype.getService = function (hash) {
37
+ return this.table.intern(hash);
38
+ };
39
+ StatTranx.prototype.send = function (now) {
40
+ if(this.table.size() === 0) {
41
+ return;
42
+ }
43
+ var p = undefined;
44
+ if(conf.stat_service1_enabled){
45
+ p = new StatServicePack1().setRecords(this.table.size(), this.table.values());
46
+ p.spec = conf.mtrace_spec_hash;
47
+ }else{
48
+ p = new StatServicePack().setRecords(this.table.size(), this.table.values());
49
+ }
50
+ p.time = now;
51
+ this.table.clear();
52
+ DataPackSender.sendStatServicePack(p);
53
+ };
54
+ StatTranx.prototype.clear = function () {
55
+ this.table.clear();
56
+ };
57
+
58
58
  module.exports = new StatTranx();
@@ -1,160 +1,160 @@
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
- AnyList = require('../util/anylist'),
9
- StatGeneralPack = require('../pack/stat-general-pack'),
10
- DataPackSender = require('../data/datapack-sender'),
11
- Logger = require('../logger'),
12
- HashUtil = require('../util/hashutil'),
13
- StringUtil = require('../util/string-util'),
14
- DataTextAgent = require('../data/datatext-agent'),
15
- conf = require('../conf/configure'),
16
- TimeCount = require('../pack/time-count');
17
-
18
- const TABLE_MAX_SIZE = 5000;
19
-
20
- function PK(caller_pcode, caller_okind, caller_spec, caller_url, url) {
21
- this.caller_pcode = caller_pcode;
22
- this.caller_okind = caller_okind;
23
- this.caller_spec = caller_spec ;
24
- this.caller_url = caller_url;
25
- this.url = url ;
26
- }
27
-
28
- PK.prototype.hashCode = function () {
29
- if(this._hash_){
30
- return this._hash_;
31
- }
32
- var prime = 31;
33
- var result = 1;
34
- result = prime * result + this.caller_pcode;
35
- result = prime * result + this.caller_okind;
36
- result = prime * result + this.caller_spec;
37
- result = prime * result + this.caller_url;
38
- result = prime * result + this.url;
39
- this._hash_=result;
40
- return result;
41
- };
42
- PK.prototype.equals = function (other) {
43
- if(this === other) {
44
- return true;
45
- }
46
- if(other == null) {
47
- return false;
48
- }
49
- if(other instanceof PK === false) {
50
- return false;
51
- }
52
- return this.caller_pcode === other.caller_pcode
53
- && this.caller_okind === other.caller_okind
54
- && this.caller_spec === other.caller_spec
55
- && this.caller_url === other.caller_url
56
- && this.url === other.url;
57
- };
58
-
59
-
60
- function StatTranxMtCaller() {
61
- if(typeof StatTranxMtCaller.instance === 'object') {
62
- return StatTranxMtCaller.instance;
63
- }
64
-
65
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
66
- this.table.create = function (key) {
67
- if(this.size() >= TABLE_MAX_SIZE) {
68
- return null;
69
- }
70
- return new TimeCount();
71
- };
72
-
73
- conf.on('stat_mtrace_max_count', function(props){
74
- StatTranxMtCaller.instance.table.setMax(props);
75
- })
76
-
77
- StatTranxMtCaller.instance = this;
78
- }
79
-
80
- StatTranxMtCaller.prototype.getService = function (caller_pcode, caller_okind, caller_spec, caller_url,url) {
81
- return this.table.intern(new PK(caller_pcode,caller_okind,caller_spec, caller_url, url));
82
- };
83
- StatTranxMtCaller.prototype.add = function (caller_pcode, caller_spec, caller_url, url,
84
- time, isErr) {
85
- try {
86
- var rec = this.getService(caller_pcode, caller_spec, caller_url,url);
87
- if(rec) {
88
- rec.count++;
89
- if(isErr){
90
- rec.error++;
91
- }
92
- rec.toime +=time;
93
- }
94
- } catch(e) {
95
- Logger.printError("WHATAP-610", "StatTranxMtCaller add error", e, false);
96
- }
97
- };
98
- StatTranxMtCaller.prototype.send = function (now) {
99
- if(this.table.size() === 0) {
100
- return;
101
- }
102
- var mtrace_spec_hash = 0;
103
- // if(conf.mtrace_spec) {
104
- // mtrace_spec_hash = HashUtil.hash(conf.mtrace_spec);
105
- // DataTextAgent.MTRACE_SPEC.add(mtrace_spec_hash,conf.mtrace_spec);
106
- // }
107
- if( StringUtil.isNotEmpty(conf.mtrace_spec) ){
108
- DataTextAgent.MTRACE_SPEC.add(conf.mtrace_spec_hash, conf.mtrace_spec);
109
- }
110
-
111
- var rsize=this.table.size();
112
- var caller_pcode =new AnyList(AnyList.LONG, rsize); /*pcode=LONG*/
113
- var caller_okind =new AnyList(AnyList.INT, rsize);
114
- var caller_spec =new AnyList(AnyList.INT, rsize);
115
- var caller_url =new AnyList(AnyList.INT, rsize);
116
- var spec =new AnyList(AnyList.INT, rsize);
117
- var url =new AnyList(AnyList.INT, rsize);
118
- var count = new AnyList(AnyList.INT, rsize);
119
- var error = new AnyList(AnyList.INT, rsize);
120
- var time = new AnyList(AnyList.LONG, rsize);
121
-
122
- var en = this.table.entries();
123
- for (var i = 0; i<rsize && en.hasMoreElements(); i++) {
124
- var ent = en.nextElement();
125
- var k = ent.getKey();
126
- var v = ent.getValue();
127
-
128
- caller_pcode.put(i, k.caller_pcode);
129
- caller_okind.put(i, k.caller_okind);
130
- caller_spec.put(i, k.caller_spec);
131
- caller_url.put(i, k.caller_url);
132
- spec.put(i, mtrace_spec_hash);
133
- url.put(i, k.url);
134
- count.put(i, v.count);
135
- error.put(i, v.error);
136
- time.put(i, v.time);
137
- }
138
- this.table.clear();
139
-
140
- var out = new StatGeneralPack();
141
- out.put("caller_pcode", caller_pcode);
142
- out.put("caller_okind", caller_okind);
143
- out.put("caller_spec", caller_spec);
144
- out.put("caller_url", caller_url);
145
- out.put("spec", spec);
146
- out.put("url", url);
147
- out.put("count", count);
148
- out.put("error", error);
149
- out.put("time", time);
150
-
151
- out.id = "mt";
152
- out.time = now;
153
-
154
- DataPackSender.sendPack(out);
155
- };
156
- StatTranxMtCaller.prototype.clear = function () {
157
- this.table.clear();
158
- };
159
-
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
+ AnyList = require('../util/anylist'),
9
+ StatGeneralPack = require('../pack/stat-general-pack'),
10
+ DataPackSender = require('../data/datapack-sender'),
11
+ Logger = require('../logger'),
12
+ HashUtil = require('../util/hashutil'),
13
+ StringUtil = require('../util/string-util'),
14
+ DataTextAgent = require('../data/datatext-agent'),
15
+ conf = require('../conf/configure'),
16
+ TimeCount = require('../pack/time-count');
17
+
18
+ const TABLE_MAX_SIZE = 5000;
19
+
20
+ function PK(caller_pcode, caller_okind, caller_spec, caller_url, url) {
21
+ this.caller_pcode = caller_pcode;
22
+ this.caller_okind = caller_okind;
23
+ this.caller_spec = caller_spec ;
24
+ this.caller_url = caller_url;
25
+ this.url = url ;
26
+ }
27
+
28
+ PK.prototype.hashCode = function () {
29
+ if(this._hash_){
30
+ return this._hash_;
31
+ }
32
+ var prime = 31;
33
+ var result = 1;
34
+ result = prime * result + this.caller_pcode;
35
+ result = prime * result + this.caller_okind;
36
+ result = prime * result + this.caller_spec;
37
+ result = prime * result + this.caller_url;
38
+ result = prime * result + this.url;
39
+ this._hash_=result;
40
+ return result;
41
+ };
42
+ PK.prototype.equals = function (other) {
43
+ if(this === other) {
44
+ return true;
45
+ }
46
+ if(other == null) {
47
+ return false;
48
+ }
49
+ if(other instanceof PK === false) {
50
+ return false;
51
+ }
52
+ return this.caller_pcode === other.caller_pcode
53
+ && this.caller_okind === other.caller_okind
54
+ && this.caller_spec === other.caller_spec
55
+ && this.caller_url === other.caller_url
56
+ && this.url === other.url;
57
+ };
58
+
59
+
60
+ function StatTranxMtCaller() {
61
+ if(typeof StatTranxMtCaller.instance === 'object') {
62
+ return StatTranxMtCaller.instance;
63
+ }
64
+
65
+ this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
66
+ this.table.create = function (key) {
67
+ if(this.size() >= TABLE_MAX_SIZE) {
68
+ return null;
69
+ }
70
+ return new TimeCount();
71
+ };
72
+
73
+ conf.on('stat_mtrace_max_count', function(props){
74
+ StatTranxMtCaller.instance.table.setMax(props);
75
+ })
76
+
77
+ StatTranxMtCaller.instance = this;
78
+ }
79
+
80
+ StatTranxMtCaller.prototype.getService = function (caller_pcode, caller_okind, caller_spec, caller_url,url) {
81
+ return this.table.intern(new PK(caller_pcode,caller_okind,caller_spec, caller_url, url));
82
+ };
83
+ StatTranxMtCaller.prototype.add = function (caller_pcode, caller_spec, caller_url, url,
84
+ time, isErr) {
85
+ try {
86
+ var rec = this.getService(caller_pcode, caller_spec, caller_url,url);
87
+ if(rec) {
88
+ rec.count++;
89
+ if(isErr){
90
+ rec.error++;
91
+ }
92
+ rec.toime +=time;
93
+ }
94
+ } catch(e) {
95
+ Logger.printError("WHATAP-610", "StatTranxMtCaller add error", e, false);
96
+ }
97
+ };
98
+ StatTranxMtCaller.prototype.send = function (now) {
99
+ if(this.table.size() === 0) {
100
+ return;
101
+ }
102
+ var mtrace_spec_hash = 0;
103
+ // if(conf.mtrace_spec) {
104
+ // mtrace_spec_hash = HashUtil.hash(conf.mtrace_spec);
105
+ // DataTextAgent.MTRACE_SPEC.add(mtrace_spec_hash,conf.mtrace_spec);
106
+ // }
107
+ if( StringUtil.isNotEmpty(conf.mtrace_spec) ){
108
+ DataTextAgent.MTRACE_SPEC.add(conf.mtrace_spec_hash, conf.mtrace_spec);
109
+ }
110
+
111
+ var rsize=this.table.size();
112
+ var caller_pcode =new AnyList(AnyList.LONG, rsize); /*pcode=LONG*/
113
+ var caller_okind =new AnyList(AnyList.INT, rsize);
114
+ var caller_spec =new AnyList(AnyList.INT, rsize);
115
+ var caller_url =new AnyList(AnyList.INT, rsize);
116
+ var spec =new AnyList(AnyList.INT, rsize);
117
+ var url =new AnyList(AnyList.INT, rsize);
118
+ var count = new AnyList(AnyList.INT, rsize);
119
+ var error = new AnyList(AnyList.INT, rsize);
120
+ var time = new AnyList(AnyList.LONG, rsize);
121
+
122
+ var en = this.table.entries();
123
+ for (var i = 0; i<rsize && en.hasMoreElements(); i++) {
124
+ var ent = en.nextElement();
125
+ var k = ent.getKey();
126
+ var v = ent.getValue();
127
+
128
+ caller_pcode.put(i, k.caller_pcode);
129
+ caller_okind.put(i, k.caller_okind);
130
+ caller_spec.put(i, k.caller_spec);
131
+ caller_url.put(i, k.caller_url);
132
+ spec.put(i, mtrace_spec_hash);
133
+ url.put(i, k.url);
134
+ count.put(i, v.count);
135
+ error.put(i, v.error);
136
+ time.put(i, v.time);
137
+ }
138
+ this.table.clear();
139
+
140
+ var out = new StatGeneralPack();
141
+ out.put("caller_pcode", caller_pcode);
142
+ out.put("caller_okind", caller_okind);
143
+ out.put("caller_spec", caller_spec);
144
+ out.put("caller_url", caller_url);
145
+ out.put("spec", spec);
146
+ out.put("url", url);
147
+ out.put("count", count);
148
+ out.put("error", error);
149
+ out.put("time", time);
150
+
151
+ out.id = "mt";
152
+ out.time = now;
153
+
154
+ DataPackSender.sendPack(out);
155
+ };
156
+ StatTranxMtCaller.prototype.clear = function () {
157
+ this.table.clear();
158
+ };
159
+
160
160
  module.exports = new StatTranxMtCaller();