whatap 0.5.26 → 1.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +78 -32
  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 +882 -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 -10
  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
@@ -173,10 +173,10 @@ EscapeLiteralSQL.prototype._quotation = function () {
173
173
  break;
174
174
  case STAT.ALPHABET:
175
175
  this.parsedSql += this.chars[this.pos];
176
- this.status = STAT.QUOTATION;
176
+ status = STAT.QUOTATION;
177
177
  break;
178
178
  case STAT.NUMBER:
179
- this.parsedSql += this.chars[this.pos];
179
+ parsedSql += this.chars[this.pos];
180
180
  this.status = STAT.QUOTATION;
181
181
  break;
182
182
  case STAT.QUOTATION:
@@ -194,16 +194,16 @@ EscapeLiteralSQL.prototype._dquotation = function () {
194
194
  }
195
195
  this.param += this.chars[this.pos];
196
196
  this.status = STAT.DQUOTATION;
197
- break;
197
+ break;;
198
198
  case STAT.COMMENT:
199
199
  this.parsedSql += this.chars[this.pos];
200
200
  break;
201
201
  case STAT.ALPHABET:
202
202
  this.parsedSql += this.chars[this.pos];
203
- this.status = STAT.DQUOTATION;
203
+ status = STAT.DQUOTATION;
204
204
  break;
205
205
  case STAT.NUMBER:
206
- this.parsedSql += this.chars[this.pos];
206
+ parsedSql += this.chars[this.pos];
207
207
  this.status = STAT.DQUOTATION;
208
208
  break;
209
209
  case STAT.DQUOTATION:
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
 
8
- var Buffer = require('buffer').Buffer;
8
+ var Buffer = require('buffer').Buffer;
9
9
 
10
- const CRC_TABLE = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
10
+ const CRC_TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
11
11
  0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
12
12
  0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064,
13
13
  0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551,
@@ -49,10 +49,10 @@ const CRC_TABLE = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
49
49
  0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f,
50
50
  0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
51
51
  0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02,
52
- 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d ];
52
+ 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
53
53
 
54
- for(var i = 0 ; i < CRC_TABLE.length; i ++){
55
- CRC_TABLE[i] = hexToInt( CRC_TABLE[i].toString(16) );
54
+ for (var i = 0; i < CRC_TABLE.length; i++) {
55
+ CRC_TABLE[i] = hexToInt(CRC_TABLE[i].toString(16));
56
56
  }
57
57
 
58
58
  function hexToInt(hex) {
@@ -68,35 +68,35 @@ function hexToInt(hex) {
68
68
  }
69
69
 
70
70
  var hashUtil = {
71
- crc32 : function(str) {
71
+ crc32: function (str) {
72
72
  var buf = Buffer.alloc(str.length);
73
73
  buf.write(str, 'utf-8');
74
74
  var crc = 0;
75
75
  crc = crc ^ (-1);
76
- for ( var n = 0; n < buf.length; n++) {
76
+ for (var n = 0; n < buf.length; n++) {
77
77
  crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
78
78
  }
79
79
  return crc ^ (-1);
80
80
  },
81
- toStr: function(n,def){
82
- if(n){
81
+ toStr: function (n, def) {
82
+ if (n) {
83
83
  return n.toString();
84
84
  }
85
- return def? def:'';
85
+ return def ? def : '';
86
86
  },
87
- hashFromString: function(str){
88
- if(str){
89
- return this.hash(Buffer.from(str));
90
- }else{
91
- return 0;
87
+ hashFromString: function (str) {
88
+ if (str) {
89
+ return this.hash(Buffer.from(str));
90
+ } else {
91
+ return 0;
92
92
  }
93
93
  },
94
- hash: function(bytes /* bytes[] */){
94
+ hash: function (bytes /* bytes[] */) {
95
95
  var crc = -1;
96
96
  var var2 = bytes;
97
97
  var var3 = bytes.length;
98
98
 
99
- for(var var4 = 0 ; var4 < var3; ++var4){
99
+ for (var var4 = 0; var4 < var3; ++var4) {
100
100
  var b = var2[var4];
101
101
  crc = crc >>> 8 ^ CRC_TABLE[(crc ^ b) & 255];
102
102
  }
@@ -104,7 +104,7 @@ var hashUtil = {
104
104
  crc = crc ^ 0xffffffff;
105
105
  return crc;
106
106
  },
107
- toInt: function(buf /* buf[] */){
107
+ toInt: function (buf /* buf[] */) {
108
108
  var ch1 = buf[0] & 255;
109
109
  var ch2 = buf[1] & 255;
110
110
  var ch3 = buf[2] & 255;
@@ -11,6 +11,9 @@ var Long = require('long'),
11
11
 
12
12
  var KeyGen = {
13
13
  next : function () {
14
+ return parseInt((Long.fromBits(rand.int32(), rand.int32())).toString());
15
+ },
16
+ getMtid : function () {
14
17
  return Long.fromBits(rand.int32(), rand.int32());
15
18
  }
16
19
  };
@@ -265,8 +265,9 @@ LinkedSetEnumerator.prototype.nextElement = function () {
265
265
  let e = this.entry;
266
266
  this.entry = e.link_next;
267
267
  return e.key;
268
+ } else {
269
+ return null;
268
270
  }
269
- throw new Error('No more elements');
270
271
  };
271
272
 
272
273
  LinkedSet.MODE = {
@@ -25,7 +25,6 @@ function getPackageJson() {
25
25
  }
26
26
  NodeUtil.packageJson = {};
27
27
  }
28
-
29
28
  function recursiveCall(fullPath, file, cb){
30
29
  if(fullPath === undefined) return;
31
30
 
@@ -114,4 +113,4 @@ var NodeUtil = {
114
113
  }
115
114
  };
116
115
 
117
- module.exports = NodeUtil;
116
+ module.exports = NodeUtil;
@@ -0,0 +1,178 @@
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 ParsedSql = require('../trace/parsed-sql'),
8
+ EscapeLiteralSQL = require('./escape-literal-sql'),
9
+ HashUtil = require('./hashutil'),
10
+ Logger = require('../logger'),
11
+ DateUtil = require('./dateutil');
12
+
13
+ /**
14
+ * SQL 리터럴을 이스케이프하고 파싱된 SQL 객체를 반환합니다.
15
+ * @param {string} sql - 원본 SQL 문자열
16
+ * @param {IntKeyMap} checkedSqlCache - 파라미터가 있는 SQL 캐시
17
+ * @param {IntKeyMap} nonLiteSqlCache - 파라미터가 없는 SQL 캐시
18
+ * @param {string} currentDate - 현재 날짜 (캐시 클리어용)
19
+ * @returns {ParsedSql} 파싱된 SQL 객체 (type, sql hash, parameters 포함)
20
+ */
21
+ function escapeLiteral(sql, checkedSqlCache, nonLiteSqlCache, currentDate) {
22
+ if (sql == null) {
23
+ sql = '';
24
+ }
25
+
26
+ var sqlHash = HashUtil.hashFromString(sql);
27
+ var psql = nonLiteSqlCache.get(sqlHash);
28
+
29
+ // 캐시에서 찾기 (literal이 없는 경우)
30
+ if (psql != null) {
31
+ return psql;
32
+ }
33
+
34
+ // 캐시에서 찾기 (literal이 있는 경우)
35
+ psql = checkedSqlCache.get(sqlHash);
36
+ if (psql != null) {
37
+ return psql;
38
+ }
39
+
40
+ // SQL 파싱 및 리터럴 이스케이프
41
+ var els = new EscapeLiteralSQL(sql);
42
+ els.process();
43
+
44
+ var hash = HashUtil.hashFromString(els.getParsedSql());
45
+
46
+ // 원본과 파싱된 SQL이 동일한 경우 (리터럴이 없음)
47
+ if (hash === sqlHash) {
48
+ psql = new ParsedSql(els.sqlType, hash, null);
49
+ nonLiteSqlCache.put(sqlHash, psql);
50
+ } else {
51
+ // 리터럴이 있어서 파싱된 경우
52
+ psql = new ParsedSql(els.sqlType, hash, els.getParameter());
53
+ checkedSqlCache.put(sqlHash, psql);
54
+ }
55
+
56
+ return psql;
57
+ }
58
+
59
+ /**
60
+ * SQL 타입을 문자열로 변환합니다.
61
+ * @param {string} sqlType - SQL 타입 ('S', 'I', 'U', 'D' 등)
62
+ * @returns {string} SQL 타입 설명
63
+ */
64
+ function getSqlTypeDescription(sqlType) {
65
+ switch (sqlType) {
66
+ case 'S': return 'SELECT';
67
+ case 'I': return 'INSERT';
68
+ case 'U': return 'UPDATE';
69
+ case 'D': return 'DELETE';
70
+ case 'C': return 'CREATE';
71
+ case 'A': return 'ALTER';
72
+ case 'R': return 'DROP';
73
+ default: return 'UNKNOWN';
74
+ }
75
+ }
76
+
77
+ /**
78
+ * SQL이 SELECT 쿼리인지 확인합니다.
79
+ * @param {ParsedSql} psql - 파싱된 SQL 객체
80
+ * @returns {boolean} SELECT 쿼리 여부
81
+ */
82
+ function isSelectQuery(psql) {
83
+ return psql && psql.type === 'S';
84
+ }
85
+
86
+ /**
87
+ * SQL이 DML(Data Manipulation Language) 쿼리인지 확인합니다.
88
+ * @param {ParsedSql} psql - 파싱된 SQL 객체
89
+ * @returns {boolean} DML 쿼리 여부 (SELECT, INSERT, UPDATE, DELETE)
90
+ */
91
+ function isDMLQuery(psql) {
92
+ return psql && ['S', 'I', 'U', 'D'].includes(psql.type);
93
+ }
94
+
95
+ /**
96
+ * SQL이 DDL(Data Definition Language) 쿼리인지 확인합니다.
97
+ * @param {ParsedSql} psql - 파싱된 SQL 객체
98
+ * @returns {boolean} DDL 쿼리 여부 (CREATE, ALTER, DROP)
99
+ */
100
+ function isDDLQuery(psql) {
101
+ return psql && ['C', 'A', 'R'].includes(psql.type);
102
+ }
103
+
104
+ /**
105
+ * 캐시 날짜를 확인하고 필요시 클리어합니다.
106
+ * @param {IntKeyMap} checkedSqlCache - 파라미터가 있는 SQL 캐시
107
+ * @param {IntKeyMap} nonLiteSqlCache - 파라미터가 없는 SQL 캐시
108
+ * @param {string} lastDate - 마지막 캐시 날짜
109
+ * @param {string} observerName - Observer 이름 (로그용)
110
+ * @returns {string} 현재 날짜
111
+ */
112
+ function checkAndClearCache(checkedSqlCache, nonLiteSqlCache, lastDate, observerName) {
113
+ var currentDate = DateUtil.yyyymmdd();
114
+
115
+ if (lastDate !== currentDate) {
116
+ checkedSqlCache.clear();
117
+ nonLiteSqlCache.clear();
118
+ Logger.print('WHATAP-SQL-CLEAR', `${observerName} CLEAR OK!!!!!!!!!!!!!!!!`, false);
119
+ }
120
+
121
+ return currentDate;
122
+ }
123
+
124
+ /**
125
+ * SQL 캐시 통계 정보를 반환합니다.
126
+ * @param {IntKeyMap} checkedSqlCache - 파라미터가 있는 SQL 캐시
127
+ * @param {IntKeyMap} nonLiteSqlCache - 파라미터가 없는 SQL 캐시
128
+ * @param {string} lastDate - 마지막 캐시 날짜
129
+ * @returns {Object} 캐시 통계 정보
130
+ */
131
+ function getCacheStats(checkedSqlCache, nonLiteSqlCache, lastDate) {
132
+ return {
133
+ checkedSqlSize: checkedSqlCache.size(),
134
+ nonLiteSqlSize: nonLiteSqlCache.size(),
135
+ checkedSqlMaxSize: checkedSqlCache.getMax(),
136
+ nonLiteSqlMaxSize: nonLiteSqlCache.getMax(),
137
+ lastClearDate: lastDate
138
+ };
139
+ }
140
+
141
+ /**
142
+ * SQL 문자열을 안전하게 자릅니다.
143
+ * @param {string} sql - SQL 문자열
144
+ * @param {number} maxLength - 최대 길이 (기본값: 200)
145
+ * @returns {string} 잘린 SQL 문자열
146
+ */
147
+ function truncateSql(sql, maxLength) {
148
+ maxLength = maxLength || 200;
149
+ if (!sql || typeof sql !== 'string') {
150
+ return '';
151
+ }
152
+ return sql.length > maxLength ? sql.substring(0, maxLength) + '...' : sql;
153
+ }
154
+
155
+ /**
156
+ * SQL 문자열을 정규화합니다 (공백 정리).
157
+ * @param {string} sql - SQL 문자열
158
+ * @returns {string} 정규화된 SQL 문자열
159
+ */
160
+ function normalizeSql(sql) {
161
+ if (!sql || typeof sql !== 'string') {
162
+ return '';
163
+ }
164
+ return sql.trim().replace(/\s+/g, ' ');
165
+ }
166
+
167
+ // 내보내기
168
+ module.exports = {
169
+ escapeLiteral: escapeLiteral,
170
+ checkAndClearCache: checkAndClearCache,
171
+ getCacheStats: getCacheStats,
172
+ getSqlTypeDescription: getSqlTypeDescription,
173
+ isSelectQuery: isSelectQuery,
174
+ isDMLQuery: isDMLQuery,
175
+ isDDLQuery: isDDLQuery,
176
+ truncateSql: truncateSql,
177
+ normalizeSql: normalizeSql
178
+ };
@@ -0,0 +1,91 @@
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
+ KeyGen = require('./keygen');
9
+
10
+ var TraceHelper = {
11
+ check_seq: 1
12
+ };
13
+
14
+ /**
15
+ * Inter-transaction trace auto-on functionality
16
+ * Used for multi-transaction tracing based on sampling rate
17
+ */
18
+ TraceHelper.interTxTraceAutoOn = function(ctx) {
19
+ if (conf.mtrace_enabled == false || ctx.httpc_checked || !ctx.mtid.isZero())
20
+ return;
21
+
22
+ ctx.httpc_checked = true;
23
+
24
+ if (conf.mtrace_rate >= 100) {
25
+ ctx.mtid = KeyGen.getMtid();
26
+ return;
27
+ }
28
+
29
+ TraceHelper.check_seq++;
30
+
31
+ switch (Math.floor(conf.mtrace_rate / 10)) {
32
+ case 10:
33
+ ctx.mtid = KeyGen.getMtid();
34
+ break;
35
+ case 9:
36
+ if (TraceHelper.check_seq % 10 !== 0)
37
+ ctx.mtid = KeyGen.getMtid();
38
+ break;
39
+ case 8:
40
+ if (TraceHelper.check_seq % 5 !== 0)
41
+ ctx.mtid = KeyGen.getMtid();
42
+ break;
43
+ case 7:
44
+ if (TraceHelper.check_seq % 4 !== 0)
45
+ ctx.mtid = KeyGen.getMtid();
46
+ break;
47
+ case 6:
48
+ if (TraceHelper.check_seq % 3 !== 0)
49
+ ctx.mtid = KeyGen.getMtid();
50
+ break;
51
+ case 5:
52
+ if (TraceHelper.check_seq % 2 === 0)
53
+ ctx.mtid = KeyGen.getMtid();
54
+ break;
55
+ case 4:
56
+ if (TraceHelper.check_seq % 3 === 0 || TraceHelper.check_seq % 5 === 0)
57
+ ctx.mtid = KeyGen.getMtid();
58
+ break;
59
+ case 3:
60
+ if (TraceHelper.check_seq % 4 === 0)
61
+ ctx.mtid = KeyGen.getMtid();
62
+ break;
63
+ case 2:
64
+ if (TraceHelper.check_seq % 5 === 0)
65
+ ctx.mtid = KeyGen.getMtid();
66
+ break;
67
+ case 1:
68
+ if (TraceHelper.check_seq % 10 === 0)
69
+ ctx.mtid = KeyGen.getMtid();
70
+ break;
71
+ case 0:
72
+ default:
73
+ break;
74
+ }
75
+ };
76
+
77
+ /**
78
+ * Reset the sequence counter (useful for testing or long-running processes)
79
+ */
80
+ TraceHelper.resetSequence = function() {
81
+ TraceHelper.check_seq = 1;
82
+ };
83
+
84
+ /**
85
+ * Get current sequence counter (for debugging)
86
+ */
87
+ TraceHelper.getSequence = function() {
88
+ return TraceHelper.check_seq;
89
+ };
90
+
91
+ module.exports = TraceHelper;
@@ -0,0 +1,58 @@
1
+ const conf = require('../conf/configure');
2
+ const Hexa32 = require("../util/hexa32");
3
+
4
+ var Transfer = function () {
5
+ this.PCODE = 0;
6
+ this.OID = 0;
7
+ this.ONAME = null;
8
+ this.OKIND = 0;
9
+ this.OKIND_NAME = null;
10
+ this.ONODE = 0;
11
+ this.ONODE_NAME = null;
12
+ this.transfer_poid;
13
+
14
+ this.PCODE = conf.on('PCODE', function (PCODE) {
15
+ this.PCODE = PCODE;
16
+ });
17
+ this.OID = conf.on('OID', function (OID) {
18
+ this.OID = OID;
19
+ });
20
+ this.ONAME = conf.on('ONAME', function (ONAME) {
21
+ this.ONAME = ONAME;
22
+ });
23
+ this.OKIND = conf.on('OKIND', function (OKIND) {
24
+ this.OKIND = OKIND;
25
+ });
26
+ this.OKIND_NAME = conf.on('OKIND_NAME', function (OKIND_NAME) {
27
+ this.OKIND_NAME = OKIND_NAME;
28
+ });
29
+ this.ONODE = conf.on('ONODE', function (ONODE) {
30
+ this.ONODE = ONODE;
31
+ });
32
+ this.ONODE_NAME = conf.on('ONODE_NAME', function (ONODE_NAME) {
33
+ this.ONODE_NAME = ONODE_NAME;
34
+ });
35
+ }
36
+
37
+ Transfer.prototype.POID = function () {
38
+ if (this.transfer_poid)
39
+ return this.transfer_poid;
40
+ this.transfer_poid = Hexa32.toString32(this.PCODE) + ',' + Hexa32.toString32(this.OKIND) + ',' + Hexa32.toString32(this.OID);
41
+ return this.transfer_poid;
42
+ }
43
+ Transfer.prototype.MTID_CALLERTX = function (ctx) {
44
+ if (ctx.transfer_id)
45
+ return ctx.transfer_id;
46
+ var x = Hexa32.toString32(ctx.mtid) + ',' + (ctx.mdepth + 1) + ',' + Hexa32.toString32(ctx.id);
47
+ ctx.transfer_id = x;
48
+ return ctx.transfer_id;
49
+ }
50
+ Transfer.prototype.SPEC_URL = function (ctx) {
51
+ if (ctx.transfer_info)
52
+ return ctx.transfer_info;
53
+ var x = conf.mtrace_spec + ',' + ctx.service_hash;
54
+ ctx.transfer_info = x;
55
+ return ctx.transfer_info;
56
+ }
57
+
58
+ module.exports = new Transfer();
@@ -132,7 +132,7 @@ MapValue.prototype.getValueType = function() {
132
132
  };
133
133
  MapValue.prototype.write = function(dout) {
134
134
  dout.writeDecimal(this.table.size());
135
- var en = this.table.keys();
135
+ var en = this.table.keys();
136
136
  while(en.hasMoreElements()) {
137
137
  var key = en.nextElement();
138
138
  dout.writeText(key);
@@ -160,7 +160,7 @@ MapValue.prototype.toObject = function() {
160
160
  return this.table;
161
161
  };
162
162
  MapValue.prototype.putAllMap = function(m) {
163
- var en = m.keys();
163
+ var en = m.keys();
164
164
  while(en.hasMoreElements()) {
165
165
  var key = en.nextElement();
166
166
  var value =m.get(key);
@@ -172,7 +172,6 @@ MapValue.prototype.putAllMap = function(m) {
172
172
  MapValue.prototype.putAllMapValue = function(m) {
173
173
  this.putAllMap(m);
174
174
  };
175
-
176
175
  MapValue.prototype.internList = function (key) {
177
176
  let lv = this.table.get(key);
178
177
  if(!lv){
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "whatap",
3
3
  "homepage": "http://www.whatap.io",
4
- "version": "0.5.26",
5
- "releaseDate": "20250825",
4
+ "version": "1.0.0-canary.0",
5
+ "releaseDate": "20250924",
6
6
  "description": "Monitoring and Profiling Service",
7
7
  "main": "index.js",
8
8
  "scripts": {},
@@ -11,18 +11,13 @@
11
11
  },
12
12
  "license": "UNLICENSED",
13
13
  "engines": {
14
- "node": ">=v16.4.0"
14
+ "node": ">=17"
15
15
  },
16
16
  "dependencies": {
17
- "crypto": "^1.0.1",
18
- "df": "^1.1.1",
19
17
  "long": "^3.2.0",
20
- "pidusage": "^1.1.0"
18
+ "proper-lockfile": "^4.1.2"
21
19
  },
22
20
  "devDependencies": {
23
- "crypto": "^1.0.1",
24
- "df": "^1.1.1",
25
- "long": "^3.2.0",
26
- "pidusage": "^1.1.0"
21
+ "long": "^3.2.0"
27
22
  }
28
23
  }
package/whatap.conf CHANGED
@@ -1,2 +1,5 @@
1
1
  license=XXXXXXXXXXXXXX-XXXXXXXXXXXXXX-XXXXXXXXXXXXXX
2
- whatap.server.host=XXX.XXX.XXX.XXX
2
+ whatap.server.host=XXX.XXX.XXX.XXX
3
+
4
+ app_name=XXX
5
+ app_process_name=node
@@ -1,101 +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 WHATAP_CONF = process.env.WHATAP_CONF || 'whatap';
8
-
9
- var fs = require('fs'),
10
- path = require('path'),
11
- EventEmitter = require('events').EventEmitter;
12
-
13
- var DataInputX = require('./../io/data-inputx'),
14
- secu = require('./../net/security-master'),
15
- NodeUtil = require('./../util/nodeutil'),
16
- HashUtil = require('./../util/hashutil'),
17
- StringUtil = require('./../util/string-util'),
18
- Cypher = require('./../util/cypher'),
19
- ConfigDefault = require("./config-default"),
20
- MapValue = require('./../value/map-value'),
21
- ConfigUtil = require('../util/config-util'),
22
- SystemUtil = require('../util/system-util'),
23
- LinuxProcStatUtil = require('./../counter/task/res/util/linuxProcStatUtil'),
24
- lastModifiedTime = 0;
25
-
26
- var num = ConfigUtil.num;
27
- var str = ConfigUtil.str;
28
- var bool = ConfigUtil.bool;
29
-
30
- var ConfSysMon = function() {
31
- var self = this;
32
- EventEmitter.call(this);
33
-
34
- this.aws_ecs_enabled = false;
35
- this.linux_proc_stat_enabled = false;
36
- this.shell_perf_enabled = false;
37
-
38
- this.correction_factor_cpu = 1;
39
- this.correction_factor_pcpu = 1;
40
- };
41
-
42
- ConfSysMon.prototype = new EventEmitter();
43
- ConfSysMon.prototype.constructor = ConfSysMon;
44
-
45
- ConfSysMon.prototype.apply = function(properties) {
46
-
47
- try {
48
- var meta_uri = process.env["ECS_CONTAINER_METADATA_URI"];
49
- this.aws_ecs_enabled = meta_uri != null;
50
- if (this.aws_ecs_enabled) {
51
- this.aws_ecs_enabled = bool(conf["whatap.ecs.enabled"], true);
52
- }
53
- } catch (e) {
54
- }
55
-
56
- this.linux_proc_stat_enabled = bool(conf["linux_proc_stat_enabled"], false);
57
- this.shell_perf_enabled = bool(conf["shell_perf_enabled"], false);
58
-
59
- this.correction_factor_cpu = num(conf["correction_factor_cpu"], 1);
60
- this.correction_factor_pcpu = num(conf["correction_factor_pcpu"], 1);
61
- }
62
-
63
- ConfSysMon.prototype.SysType = {
64
- NONE: 'NONE',
65
- ECS: 'ECS',
66
- KUBE: 'KUBE',
67
- LINUX: 'LINUX',
68
- JMX: 'JMX',
69
- SHELL: 'SHELL',
70
- SIGAR: 'SIGAR'
71
- }
72
-
73
- ConfSysMon.prototype.findType = function(){
74
- var t = this.SysType.NONE;
75
-
76
- // dynamic reload!!!
77
- var Configure = require('./configure');
78
-
79
- if (Configure.whatap_micro_enabled || process.env.WHATAP_MICRO_ENABLED === "true") {
80
- t = this.SysType.KUBE;
81
- } else if (this.aws_ecs_enabled) {
82
- t = this.SysType.ECS;
83
- } else if (this.linux_proc_stat_enabled) {
84
- if (SystemUtil.IS_LINUX && LinuxProcStatUtil.isLinux()) {
85
- t = this.SysType.LINUX;
86
- } else {
87
- t = this.SysType.JMX;
88
- }
89
- } else if (this.shell_perf_enabled) {
90
- t = this.SysType.SHELL;
91
- } /*else if (this.sigar_enabled) {
92
- t = this.SysType.SIGAR;
93
- } */else {
94
- t = this.SysType.JMX;
95
- }
96
- return t;
97
- };
98
-
99
- const conf = new ConfSysMon();
100
-
101
- module.exports = conf;
@@ -1,24 +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 Configure = require('./../conf/configure');
9
- var MapValue = require('./../value/map-value');
10
- var PropertyUtil = require('./../util/property-util');
11
-
12
- module.exports = {
13
- update: function(m /* MapValue */){
14
-
15
- },
16
- readConfig: function(){
17
- var props = Configure.getCustomProps();
18
- var mv = new MapValue();
19
- for(var k in props){
20
- mv.putString(k, props[k]);
21
- }
22
- return mv;
23
- }
24
- }