whatap 0.5.26 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/agent/darwin/arm64/whatap_nodejs +0 -0
  2. package/agent/linux/amd64/whatap_nodejs +0 -0
  3. package/agent/linux/arm64/whatap_nodejs +0 -0
  4. package/build.txt +4 -0
  5. package/lib/conf/config-default.js +3 -10
  6. package/lib/conf/configure.js +349 -369
  7. package/lib/conf/license.js +1 -1
  8. package/lib/control/packagectr-helper.js +3 -34
  9. package/lib/core/agent.js +882 -176
  10. package/lib/core/interceptor.js +6 -6
  11. package/lib/core/shimmer.js +36 -82
  12. package/lib/counter/counter-manager.js +8 -79
  13. package/lib/counter/task/activetransaction.js +17 -68
  14. package/lib/io/data-inputx.js +3 -13
  15. package/lib/io/data-outputx.js +206 -268
  16. package/lib/logger.js +6 -6
  17. package/lib/net/security-master.js +20 -139
  18. package/lib/observers/apollo-server-observer.js +27 -33
  19. package/lib/observers/global-observer.js +80 -155
  20. package/lib/observers/http-observer.js +236 -666
  21. package/lib/observers/ioredis-observer.js +294 -0
  22. package/lib/observers/maria-observer.js +362 -204
  23. package/lib/observers/mongodb-observer.js +226 -169
  24. package/lib/observers/mongoose-observer.js +323 -518
  25. package/lib/observers/mssql-observer.js +418 -177
  26. package/lib/observers/mysql-observer.js +449 -342
  27. package/lib/observers/mysql2-observer.js +358 -396
  28. package/lib/observers/oracle-observer.js +384 -559
  29. package/lib/observers/pgsql-observer.js +489 -231
  30. package/lib/observers/prisma-observer.js +92 -303
  31. package/lib/observers/process-observer.js +35 -79
  32. package/lib/observers/redis-observer.js +331 -166
  33. package/lib/observers/socket.io-observer.js +187 -226
  34. package/lib/observers/websocket-observer.js +301 -175
  35. package/lib/pack/counter-pack.js +0 -3
  36. package/lib/pack/log-sink-pack.js +52 -14
  37. package/lib/pack/tagcount-pack.js +4 -4
  38. package/lib/{counter/task → system}/gc-action.js +74 -27
  39. package/lib/trace/trace-context-manager.js +25 -113
  40. package/lib/trace/trace-context.js +7 -21
  41. package/lib/trace/trace-httpc.js +11 -17
  42. package/lib/trace/trace-sql.js +21 -29
  43. package/lib/udp/async_sender.js +119 -0
  44. package/lib/udp/index.js +17 -0
  45. package/lib/udp/packet_enum.js +52 -0
  46. package/lib/udp/packet_queue.js +69 -0
  47. package/lib/udp/packet_type_enum.js +33 -0
  48. package/lib/udp/param_def.js +72 -0
  49. package/lib/udp/udp_session.js +336 -0
  50. package/lib/util/escape-literal-sql.js +5 -5
  51. package/lib/util/hashutil.js +18 -18
  52. package/lib/util/keygen.js +3 -0
  53. package/lib/util/linkedset.js +2 -1
  54. package/lib/util/nodeutil.js +1 -2
  55. package/lib/util/sql-util.js +178 -0
  56. package/lib/util/trace-helper.js +91 -0
  57. package/lib/util/transfer.js +58 -0
  58. package/lib/value/map-value.js +2 -3
  59. package/package.json +5 -10
  60. package/lib/conf/conf-sys-mon.js +0 -101
  61. package/lib/control/cmd-config.js +0 -24
  62. package/lib/control/control-handler.js +0 -367
  63. package/lib/core/request-agent.js +0 -27
  64. package/lib/counter/meter/meter-activex.js +0 -67
  65. package/lib/counter/meter/meter-httpc.js +0 -57
  66. package/lib/counter/meter/meter-resource.js +0 -9
  67. package/lib/counter/meter/meter-service.js +0 -168
  68. package/lib/counter/meter/meter-socket.io.js +0 -51
  69. package/lib/counter/meter/meter-sql.js +0 -71
  70. package/lib/counter/meter/meter-users.js +0 -58
  71. package/lib/counter/meter.js +0 -183
  72. package/lib/counter/task/agentinfo.js +0 -107
  73. package/lib/counter/task/gcstat.js +0 -34
  74. package/lib/counter/task/heapmem.js +0 -25
  75. package/lib/counter/task/httpc.js +0 -76
  76. package/lib/counter/task/metering-info.js +0 -125
  77. package/lib/counter/task/proc-cpu.js +0 -29
  78. package/lib/counter/task/realtimeuser.js +0 -31
  79. package/lib/counter/task/res/systemECSTask.js +0 -39
  80. package/lib/counter/task/res/systemKubeTask.js +0 -53
  81. package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
  82. package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
  83. package/lib/counter/task/res-sys-cpu.js +0 -62
  84. package/lib/counter/task/service.js +0 -202
  85. package/lib/counter/task/socketio.js +0 -30
  86. package/lib/counter/task/sql.js +0 -105
  87. package/lib/counter/task/systemperf.js +0 -43
  88. package/lib/data/datapack-sender.js +0 -289
  89. package/lib/data/dataprofile-agent.js +0 -162
  90. package/lib/data/datatext-agent.js +0 -135
  91. package/lib/data/event-level.js +0 -15
  92. package/lib/data/test.js +0 -49
  93. package/lib/data/zipprofile.js +0 -197
  94. package/lib/env/constants.js +0 -21
  95. package/lib/error/error-handler.js +0 -437
  96. package/lib/kube/kube-client.js +0 -144
  97. package/lib/lang/text-types.js +0 -58
  98. package/lib/logsink/line-log-util.js +0 -87
  99. package/lib/logsink/line-log.js +0 -12
  100. package/lib/logsink/log-sender.js +0 -78
  101. package/lib/logsink/log-tracer.js +0 -40
  102. package/lib/logsink/sender-util.js +0 -56
  103. package/lib/logsink/zip/zip-send.js +0 -177
  104. package/lib/net/netflag.js +0 -55
  105. package/lib/net/receiver.js +0 -66
  106. package/lib/net/sender.js +0 -141
  107. package/lib/net/tcp-return.js +0 -18
  108. package/lib/net/tcp-session.js +0 -286
  109. package/lib/net/tcpreq-client-proxy.js +0 -70
  110. package/lib/net/tcprequest-mgr.js +0 -58
  111. package/lib/observers/cluster-observer.js +0 -22
  112. package/lib/observers/express-observer.js +0 -215
  113. package/lib/observers/file-observer.js +0 -184
  114. package/lib/observers/grpc-observer.js +0 -336
  115. package/lib/observers/memcached-observer.js +0 -56
  116. package/lib/observers/mongo-observer.js +0 -317
  117. package/lib/observers/net-observer.js +0 -77
  118. package/lib/observers/promise-observer.js +0 -31
  119. package/lib/observers/schedule-observer.js +0 -67
  120. package/lib/observers/stream-observer.js +0 -19
  121. package/lib/observers/thrift-observer.js +0 -197
  122. package/lib/pack/activestack-pack.js +0 -55
  123. package/lib/pack/apenum.js +0 -8
  124. package/lib/pack/errorsnap-pack.js +0 -69
  125. package/lib/pack/event-pack.js +0 -54
  126. package/lib/pack/hitmap-pack.js +0 -63
  127. package/lib/pack/hitmap-pack1.js +0 -152
  128. package/lib/pack/netstat.js +0 -15
  129. package/lib/pack/otype.js +0 -7
  130. package/lib/pack/profile-pack.js +0 -49
  131. package/lib/pack/realtimeuser-pack.js +0 -41
  132. package/lib/pack/stat-general-pack.js +0 -96
  133. package/lib/pack/staterror-pack.js +0 -120
  134. package/lib/pack/stathttpc-pack.js +0 -66
  135. package/lib/pack/stathttpc-rec.js +0 -78
  136. package/lib/pack/statremote-pack.js +0 -46
  137. package/lib/pack/statservice-pack.js +0 -63
  138. package/lib/pack/statservice-pack1.js +0 -88
  139. package/lib/pack/statservice-rec.js +0 -292
  140. package/lib/pack/statservice-rec_dep.js +0 -151
  141. package/lib/pack/statsql-pack.js +0 -69
  142. package/lib/pack/statsql-rec.js +0 -100
  143. package/lib/pack/statuseragent-pack.js +0 -44
  144. package/lib/pack/tagctr.js +0 -15
  145. package/lib/pack/text-pack.js +0 -50
  146. package/lib/pack/time-count.js +0 -25
  147. package/lib/pack/websocket.js +0 -15
  148. package/lib/pack/zip-pack.js +0 -70
  149. package/lib/pii/pii-item.js +0 -31
  150. package/lib/pii/pii-mask.js +0 -174
  151. package/lib/plugin/plugin-loadermanager.js +0 -57
  152. package/lib/plugin/plugin.js +0 -75
  153. package/lib/service/tx-record.js +0 -332
  154. package/lib/stat/stat-error.js +0 -116
  155. package/lib/stat/stat-httpc.js +0 -98
  156. package/lib/stat/stat-remote-ip.js +0 -46
  157. package/lib/stat/stat-remote-ipurl.js +0 -88
  158. package/lib/stat/stat-sql.js +0 -113
  159. package/lib/stat/stat-tranx.js +0 -58
  160. package/lib/stat/stat-tx-caller.js +0 -160
  161. package/lib/stat/stat-tx-domain.js +0 -111
  162. package/lib/stat/stat-tx-referer.js +0 -112
  163. package/lib/stat/stat-useragent.js +0 -48
  164. package/lib/stat/timingsender.js +0 -76
  165. package/lib/step/activestack-step.js +0 -38
  166. package/lib/step/dbc-step.js +0 -36
  167. package/lib/step/http-stepx.js +0 -67
  168. package/lib/step/message-step.js +0 -40
  169. package/lib/step/method-stepx.js +0 -45
  170. package/lib/step/resultset-step.js +0 -40
  171. package/lib/step/securemsg-step.js +0 -44
  172. package/lib/step/socket-step.js +0 -46
  173. package/lib/step/sql-stepx.js +0 -68
  174. package/lib/step/sqlxtype.js +0 -16
  175. package/lib/step/step.js +0 -66
  176. package/lib/step/stepenum.js +0 -54
  177. package/lib/topology/link.js +0 -63
  178. package/lib/topology/nodeinfo.js +0 -123
  179. package/lib/topology/status-detector.js +0 -111
  180. package/lib/util/anylist.js +0 -103
  181. package/lib/util/cardinality/hyperloglog.js +0 -106
  182. package/lib/util/cardinality/murmurhash.js +0 -31
  183. package/lib/util/cardinality/registerset.js +0 -75
  184. package/lib/util/errordata.js +0 -21
  185. package/lib/util/iputil_x.js +0 -527
  186. package/lib/util/kube-util.js +0 -73
  187. package/lib/util/paramsecurity.js +0 -80
  188. package/lib/util/pre-process.js +0 -13
  189. package/lib/util/process-seq.js +0 -166
  190. package/lib/util/property-util.js +0 -36
  191. package/lib/util/request-queue.js +0 -70
  192. package/lib/util/requestdouble-queue.js +0 -72
  193. package/lib/util/resourceprofile.js +0 -157
  194. package/lib/util/stop-watch.js +0 -30
  195. package/lib/util/system-util.js +0 -10
  196. package/lib/util/userid-util.js +0 -57
@@ -35,7 +35,7 @@ Interceptor.prototype.before = function(obj, funcs, advice, isCallback) {
35
35
  try {
36
36
  advice(this, arguments);
37
37
  } catch (e) {
38
- Logger.printError("WHATAP-500", "Interceptor error", e);
38
+ Logger.printError("WHATAP-114", "Interceptor error", e);
39
39
  }
40
40
  return orig.apply(this, arguments);
41
41
  }
@@ -60,7 +60,7 @@ Interceptor.prototype.after = function(obj, funcs, advice) {
60
60
  try {
61
61
  funcRet = advice(this, arguments, ret);
62
62
  } catch(e) {
63
- Logger.printError('WHATAP-177', 'Interceptor after error', e);
63
+ Logger.printError('WHATAP-115', 'Interceptor after error', e);
64
64
  }
65
65
 
66
66
  return funcRet || ret;
@@ -90,7 +90,7 @@ Interceptor.prototype.both = function(obj, funcs, beforeFunc, afterFunc) {
90
90
  try {
91
91
  beforeFunc(this, arguments, local_ctx);
92
92
  } catch(e) {
93
- Logger.printError('WHATAP-178', 'Interceptor both before error', e);
93
+ Logger.printError('WHATAP-116', 'Interceptor both before error', e);
94
94
  }
95
95
 
96
96
  var ret = orig.apply(this, arguments);
@@ -100,7 +100,7 @@ Interceptor.prototype.both = function(obj, funcs, beforeFunc, afterFunc) {
100
100
  funcRet = afterFunc(this, arguments, ret, local_ctx);
101
101
  }
102
102
  } catch(e) {
103
- Logger.printError("WHATAP-501", "Interceptor both after error", e);
103
+ Logger.printError("WHATAP-117", "Interceptor both after error", e);
104
104
  }
105
105
 
106
106
  return funcRet || ret;
@@ -122,7 +122,7 @@ Interceptor.prototype.functionHook = function(args, pos, beforeFunc, afterFunc)
122
122
  try {
123
123
  beforeFunc(this, arguments);
124
124
  } catch(e) {
125
- Logger.printError("WHATAP-179", 'Interceptor functionhook before error', e);
125
+ Logger.printError("WHATAP-118", 'Interceptor functionhook before error', e);
126
126
  }
127
127
  }
128
128
 
@@ -132,7 +132,7 @@ Interceptor.prototype.functionHook = function(args, pos, beforeFunc, afterFunc)
132
132
  try {
133
133
  afterFunc(this, arguments, result);
134
134
  } catch(e) {
135
- Logger.printError("WHATAP-180", 'Interceptor functionhook after error', e);
135
+ Logger.printError("WHATAP-119", 'Interceptor functionhook after error', e);
136
136
  }
137
137
  }
138
138
  return result;
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
- function isFunction(funktion) {
3
+ function isFunction (funktion) {
4
4
  return typeof funktion === 'function'
5
5
  }
6
6
 
7
- function defineProperty(obj, name, value) {
7
+ function defineProperty (obj, name, value) {
8
8
  var enumerable = !!obj[name] && obj.propertyIsEnumerable(name)
9
9
  Object.defineProperty(obj, name, {
10
10
  configurable: true,
@@ -14,28 +14,10 @@ function defineProperty(obj, name, value) {
14
14
  })
15
15
  }
16
16
 
17
- var shimmer = function() {}
18
-
19
- /**
20
- * Wrap a single method or multiple methods with the provided wrapper function
21
- *
22
- * @param {Object} nodule - The object containing methods to wrap
23
- * @param {string|Array<string>} name - Method name or array of method names to wrap
24
- * @param {Function} wrapper - The wrapper function
25
- * @returns {Function|Array<Function>} - The wrapped function(s)
26
- */
27
- var wrap = function(nodule, name, wrapper) {
28
- // If name is an array, recursively call wrap for each name in the array
29
- if (Array.isArray(name)) {
30
- var wrapped = [];
31
- name.forEach(function(methodName) {
32
- var result = wrap(nodule, methodName, wrapper);
33
- if (result) wrapped.push(result);
34
- });
35
- return wrapped.length > 0 ? wrapped : undefined;
36
- }
17
+ var shimmer = function () {
18
+ }
37
19
 
38
- // Standard single method wrap logic
20
+ var wrap = function (nodule, name, wrapper) {
39
21
  if (!nodule || !nodule[name]) {
40
22
  return;
41
23
  }
@@ -45,95 +27,67 @@ var wrap = function(nodule, name, wrapper) {
45
27
  }
46
28
 
47
29
  if (!isFunction(nodule[name]) || !isFunction(wrapper)) {
48
- return;
30
+ return
49
31
  }
50
32
 
51
- var original = nodule[name];
52
- var wrapped = wrapper(original, name);
33
+ var original = nodule[name]
34
+ var wrapped = wrapper(original, name)
53
35
 
54
- defineProperty(wrapped, '__original', original);
55
- defineProperty(wrapped, '__unwrap', function() {
56
- if (nodule[name] === wrapped) defineProperty(nodule, name, original);
57
- });
58
- defineProperty(wrapped, '__wrapped', true);
36
+ defineProperty(wrapped, '__original', original)
37
+ defineProperty(wrapped, '__unwrap', function () {
38
+ if (nodule[name] === wrapped) defineProperty(nodule, name, original)
39
+ })
40
+ defineProperty(wrapped, '__wrapped', true)
59
41
 
60
- defineProperty(nodule, name, wrapped);
61
- return wrapped;
42
+ defineProperty(nodule, name, wrapped)
43
+ return wrapped
62
44
  }
63
45
 
64
- /**
65
- * Unwrap a single method or multiple methods
66
- *
67
- * @param {Object} nodule - The object containing wrapped methods
68
- * @param {string|Array<string>} name - Method name or array of method names to unwrap
69
- */
70
- function unwrap(nodule, name) {
71
- // If name is an array, recursively call unwrap for each name in the array
72
- if (Array.isArray(name)) {
73
- name.forEach(function(methodName) {
74
- unwrap(nodule, methodName);
75
- });
76
- return;
77
- }
78
-
46
+ function unwrap (nodule, name) {
79
47
  if (!nodule || !nodule[name]) {
80
- return;
48
+ return
81
49
  }
82
50
 
83
51
  if (!nodule[name].__unwrap) {
84
- // Method is not wrapped
85
52
  } else {
86
- return nodule[name].__unwrap();
53
+ return nodule[name].__unwrap()
87
54
  }
88
55
  }
89
56
 
90
- /**
91
- * Wrap multiple methods of multiple modules with the same wrapper
92
- *
93
- * @param {Object|Array<Object>} nodules - Module or array of modules with methods to wrap
94
- * @param {Array<string>} names - Array of method names to wrap
95
- * @param {Function} wrapper - The wrapper function to apply
96
- */
97
- function massWrap(nodules, names, wrapper) {
57
+ function massWrap (nodules, names, wrapper) {
98
58
  if (!nodules) {
99
- return;
59
+ return
100
60
  } else if (!Array.isArray(nodules)) {
101
- nodules = [nodules];
61
+ nodules = [nodules]
102
62
  }
103
63
 
104
64
  if (!(names && Array.isArray(names))) {
105
- return;
65
+ return
106
66
  }
107
67
 
108
- nodules.forEach(function(nodule) {
109
- names.forEach(function(name) {
110
- wrap(nodule, name, wrapper);
111
- });
112
- });
68
+ nodules.forEach(function (nodule) {
69
+ names.forEach(function (name) {
70
+ wrap(nodule, name, wrapper)
71
+ })
72
+ })
113
73
  }
114
74
 
115
- /**
116
- * Unwrap multiple methods of multiple modules
117
- *
118
- * @param {Object|Array<Object>} nodules - Module or array of modules with wrapped methods
119
- * @param {Array<string>} names - Array of method names to unwrap
120
- */
121
- function massUnwrap(nodules, names) {
75
+ function massUnwrap (nodules, names) {
122
76
  if (!nodules) {
123
- return;
77
+ return
124
78
  } else if (!Array.isArray(nodules)) {
125
- nodules = [nodules];
79
+ nodules = [nodules]
126
80
  }
127
81
 
128
82
  if (!(names && Array.isArray(names))) {
129
- return;
83
+ return
130
84
  }
131
85
 
132
- nodules.forEach(function(nodule) {
133
- names.forEach(function(name) {
134
- unwrap(nodule, name);
135
- });
136
- });
86
+ nodules.forEach(function (nodule) {
87
+ names.forEach(function (name) {
88
+ unwrap(nodule, name)
89
+ })
90
+ })
137
91
  }
138
92
 
139
93
  shimmer.wrap = wrap;
@@ -4,70 +4,32 @@
4
4
  * can be found in the LICENSE file.
5
5
  */
6
6
 
7
- var CounterPack = require('../pack/counter-pack'),
8
- Service = require('./task/service'),
9
- AgentInfo = require('./task/agentinfo'),
10
- ActiveTransaction = require('./task/activetransaction'),
11
- ProcCpu = require('./task/proc-cpu'),
12
- ResSysCpu = require('./task/res-sys-cpu'),
13
- HeapMem = require('./task/heapmem'),
14
- SystemPerf = require('./task/systemperf'),
15
- RealtimeUser = require('./task/realtimeuser'),
16
- Socketio = require('./task/socketio'),
17
- GCStat = require('./task/gcstat'),
18
- Sql = require('./task/sql'),
19
- HttpC = require('./task/httpc'),
20
- MeteringInfo = require('./task/metering-info'),
21
- GCAction = require('./task/gc-action'),
22
- StatError = require('../stat/stat-error'),
23
- TagCounterPack = require('../pack/tagcount-pack'),
24
- TraceContextManager = require('../trace/trace-context-manager'),
7
+ var TraceContextManager = require('../trace/trace-context-manager'),
25
8
  secuMaster = require('../net/security-master'),
26
- DataPackSender = require('../data/datapack-sender'),
27
9
  conf = require('../conf/configure'),
28
10
  DateUtil = require('./../util/dateutil'),
29
- KubeClient = require('../kube/kube-client'),
30
- KubeUtil = require('../util/kube-util'),
31
- Logger = require('../logger');
11
+ Logger = require('../logger'),
12
+ GCAction = require('../system/gc-action');
32
13
 
33
14
  function CounterManager(agent) {
34
15
  this.agent = agent;
35
16
  this.time = Date.now();
36
-
17
+
37
18
  this.intervalIndex = undefined;
38
19
  };
39
20
  CounterManager.plugin={}
40
21
  CounterManager.prototype.run = function () {
41
- var self = this;
42
-
22
+ let self = this;
43
23
  process.nextTick(function () {
44
24
  var tasks = [];
45
- tasks.push(new Service());
46
- tasks.push(new AgentInfo());
47
- tasks.push(new ActiveTransaction());
48
- tasks.push(new RealtimeUser());
49
- tasks.push(new HeapMem());
50
- tasks.push(new ProcCpu());
51
- tasks.push(new ResSysCpu());
52
- tasks.push(new SystemPerf());
53
- tasks.push(new Socketio());
54
- tasks.push(new GCStat());
55
- tasks.push(new Sql());
56
- tasks.push(new HttpC());
57
25
  tasks.push(new GCAction());
58
26
 
59
- // metering
60
- tasks.push(new MeteringInfo());
61
27
  self.intervalIndex = setInterval(function(){
62
28
  self.process(tasks);
63
29
  },5000);
30
+
64
31
  self.process(tasks);
65
32
  });
66
-
67
- if(conf.whatap_micro_enabled || process.env.WHATAP_MICRO_ENABLED === "true"){
68
- KubeUtil.loadContainerId();
69
- if (conf.enabled_master_agent_call) KubeClient.run();
70
- }
71
33
  };
72
34
  CounterManager.prototype.stop = function(){
73
35
  if(this.intervalIndex){
@@ -90,49 +52,16 @@ CounterManager.prototype.process = function (tasks) {
90
52
  return;
91
53
  }
92
54
 
93
- var enumer = TraceContextManager.getContextEnumeration();
94
- while (enumer.hasMoreElements()) {
95
- var ctx = enumer.nextElement();
96
- if (ctx.getElapsedTime() > conf.profile_max_time) {
97
- //TraceContextManager.end(ctx._id);
98
- if(conf.getProperty("ignore_http_lost_connection", false) === true){
99
- Logger.print("WHATAP-072", "Lost Connection was ignored, " + ctx._id, false);
100
- TraceContextManager.end(ctx._id);
101
- ctx = null;
102
- }else{
103
- // var obj = TraceContextManager.resume(ctx._id);
104
- TraceContextManager.addStep("Lost Connection","", ctx);
105
- //ctx.status = 5;
106
- //ctx.error = StatError.addError(500, "Lost Connection", ctx.service_hash);
107
- TraceContextManager.endTrace(ctx);
108
- }
109
- }
110
- }
111
-
112
55
  if (conf.counter_enabled) {
113
- var pack = new CounterPack();
114
- pack.pcode = secuMaster.PCODE;
115
- pack.oid = secuMaster.OID;
116
- pack.time = Math.floor(DateUtil.currentTime() / 5000) * 5000;
117
- pack.duration = Math.floor(interval / 1000);
118
56
  for (var i = 0; i < len; i++) {
119
57
  task = tasks[i];
120
58
  try{
121
- task.process(pack);
59
+ task.process();
122
60
  } catch (e) {
123
- Logger.printError('WHATAP-070', 'Counter Manager process ', e, true);
61
+ Logger.printError('WHATAP-603', 'Counter Manager process ', e, true);
124
62
  }
125
63
  }
126
- pack.starttime = this.agent.starttime;
127
64
 
128
- try {
129
- if (CounterManager.plugin["extra"]) {
130
- CounterManager.plugin["extra"](pack);
131
- }
132
- } catch (e) {
133
- Logger.printError('WHATAP-071', 'Counter Manager Plugin ', e, true);
134
- }
135
- DataPackSender.sendCounterPack(pack);
136
65
  }
137
66
  };
138
67
 
@@ -4,91 +4,40 @@
4
4
  * can be found in the LICENSE file.
5
5
  */
6
6
 
7
- var CounterTask = require('./counter-task'),
8
- StatSql = require('../../stat/stat-sql'),
9
- conf = require('../../conf/configure'),
7
+ var conf = require('../../conf/configure'),
10
8
  TraceContextManager = require('../../trace/trace-context-manager'),
11
- MeterActiveX = require('../meter/meter-activex'),
12
- ActiveStackPack = require('../../pack/activestack-pack'),
13
- ActiveStackStep = require('../../step/activestack-step'),
14
- DataPackSender = require('../../data/datapack-sender'),
15
- DataTextAgent = require('../../data/datatext-agent'),
16
- MeterUsers = require('../meter/meter-users'),
17
9
  KeyGen = require('../../util/keygen'),
18
10
  HashUtil = require('../../util/hashutil'),
19
- ResourceProfile = require('../../util/resourceprofile'),
20
11
  Logger = require('../../logger'),
21
12
  Long = require('long');
22
13
 
23
- function ActiveTransaction() {
24
- CounterTask.call(this);
25
- this.last_stack_sec = 0;
26
- }
27
-
28
- ActiveTransaction.prototype = new CounterTask();
29
- ActiveTransaction.prototype.constructor = ActiveTransaction;
30
- ActiveTransaction.prototype.process = function (p) {
31
-
32
- p.active_tx_slice = [0, 0, 0];
33
- p.active_stat = new Array(5).fill(0);
34
-
35
- var activeX = null;
36
- if (conf.actx_meter_enabled) {
37
- activeX = MeterActiveX;
38
- activeX.reinit();
39
- }
40
-
14
+ function ActiveTransaction() {}
15
+ ActiveTransaction.prototype.getActiveStats = function () {
16
+ var stats = new Array(5).fill(0);
41
17
  var en = TraceContextManager.getContextEnumeration();
42
18
  try {
43
19
  while (en.hasMoreElements()) {
44
20
  var ctx = en.nextElement();
45
- if (ctx == null) {
46
- return false;
47
- }
48
- var elapsed = ctx.getElapsedTime();
49
- if (elapsed < conf.trace_active_transaction_yellow_time) {
50
- p.active_tx_slice[0]++;
51
- } else if (elapsed < conf.trace_active_transaction_red_time) {
52
- p.active_tx_slice[1]++;
53
- } else {
54
- p.active_tx_slice[2]++;
55
- if (elapsed >= conf.trace_active_transaction_hang_time) {
56
- p.act_svc_hang++;
57
- }
58
- }
59
- p.active_tx_count++;
60
- if (activeX) {
61
- activeX.addTx(ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
62
- var httpc = ctx.active_httpc_hash;
63
- if (httpc != 0) {
64
- activeX.addHttpc(httpc);
65
- } else {
66
- var dbc = ctx.active_dbc;
67
- if (dbc != 0) {
68
- activeX.addSql(dbc);
69
- }
70
- }
21
+ if (!ctx) {
22
+ break;
71
23
  }
72
-
73
-
74
- if (ctx.active_sqlhash != 0) {
75
- p.active_stat[1]++; // sql
76
- } else if (ctx.active_httpc_hash != 0) {
77
- p.active_stat[2]++; // httpc
24
+ if (ctx.active_sqlhash) {
25
+ stats[1]++;
26
+ } else if (ctx.active_httpc_hash) {
27
+ stats[2]++; // httpc
78
28
  } else if (ctx.db_opening) {
79
- p.active_stat[3]++; // dbc
29
+ stats[3]++; // dbc
80
30
  } else if (ctx.socket_connecting) {
81
- p.active_stat[4]++; // socket
31
+ stats[4]++; // socket
82
32
  } else {
83
- p.active_stat[0]++; // method
33
+ stats[0]++; // method
84
34
  }
85
-
86
- MeterUsers.addActive(ctx.userid);
87
35
  }
36
+ return stats;
88
37
  } catch (e) {
89
- Logger.printError("WHATAP-071", 'Active Transaction(process)', e)
38
+ Logger.printError("WHATAP-602", 'Active Transaction(process)', e)
39
+ return stats;
90
40
  }
91
-
92
41
  };
93
42
 
94
- module.exports = ActiveTransaction;
43
+ module.exports = new ActiveTransaction();
@@ -4,17 +4,7 @@
4
4
  * can be found in the LICENSE file.
5
5
  */
6
6
 
7
- var constants = require('../env/constants'),
8
- ValueEnum = require('../value/valueenum'),
9
- CounterPack = require('../pack/counter-pack'),
10
- ActiveStackPack = require('../pack/activestack-pack'),
11
- TextPack = require('../pack/text-pack').TextPack,
12
- StatHttpcPack = require('../pack/stathttpc-pack').StatHttpcPack,
13
- StatErrorPack = require('../pack/staterror-pack').StatErrorPack,
14
- ParamPack = require('../pack/param-pack').ParamPack,
15
- ErrorSnapPack1 = require('../pack/errorsnap-pack').ErrorSnapPack1,
16
- EventPack = require('../pack/event-pack').Instance,
17
- HitMapPack1 = require('../pack/hitmap-pack1'),
7
+ var ValueEnum = require('../value/valueenum'),
18
8
  PackEnum = require('../pack/packenum'),
19
9
  Long = require('long');
20
10
 
@@ -131,7 +121,7 @@ DataInputX.prototype.readByte = function() {
131
121
  DataInputX.prototype.readIntBytes = function(max) {
132
122
  var len = this.readInt32BE();
133
123
  if(len < 0 || len > max){
134
- Logger.printError('WHATAP-210', "read byte is overflowed max:" + max + " len:" + len, new Error());
124
+ Logger.printError('WHATAP-501', "read byte is overflowed max:" + max + " len:" + len, new Error());
135
125
  }
136
126
  return this.read(len);
137
127
  };
@@ -238,7 +228,7 @@ DataInputX.prototype.readPack = function () {
238
228
  }
239
229
  return null;
240
230
  } catch (e) {
241
- require('../logger').printError('WHATAP-211', "DataInputX (readPack)", e , false);
231
+ require('../logger').printError('WHATAP-502', "DataInputX (readPack)", e , false);
242
232
  return null;
243
233
  }
244
234
  };