whatap 0.4.44 → 0.4.47

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.
package/lib/core/agent.js CHANGED
@@ -231,15 +231,16 @@ NodeAgent.prototype.connectCB = function (cb) {
231
231
  });
232
232
  }, self.setLoopTime);
233
233
  };
234
-
234
+ const sleep = async(ms) => {
235
+ return new Promise(resolve=>{
236
+ setTimeout(resolve,ms)
237
+ })
238
+ }
235
239
  NodeAgent.prototype.loadObserves = function() {
236
240
  var agent = this;
237
241
  var observes = [];
238
242
 
239
243
  observes.push(HttpObserver);
240
- if(agent._conf['trace_node_schedule_enabled']) {
241
- observes.push(ScheduleObserver);
242
- }
243
244
  observes.push(NetObserver);
244
245
  observes.push(ClusterObserver);
245
246
  observes.push(MysqlObserver);
@@ -253,7 +254,8 @@ NodeAgent.prototype.loadObserves = function() {
253
254
  observes.push(ThriftObserver);
254
255
  observes.push(PromiseObserver);
255
256
  observes.push(PgSqlObserver);
256
-
257
+ observes.push(ScheduleObserver);
258
+
257
259
  var packageToObserve = {};
258
260
  observes.forEach(function(observeObj) {
259
261
  var observe = new observeObj(agent);
@@ -17,6 +17,7 @@ var CounterPack = require('../pack/counter-pack'),
17
17
  GCStat = require('./task/gcstat'),
18
18
  Sql = require('./task/sql'),
19
19
  HttpC = require('./task/httpc'),
20
+ StatError = require('../stat/stat-error'),
20
21
  TagCounterPack = require('../pack/tagcount-pack'),
21
22
  TraceContextManager = require('../trace/trace-context-manager'),
22
23
  secuMaster = require('../net/security-master'),
@@ -88,8 +89,12 @@ CounterManager.prototype.process = function (tasks) {
88
89
  while (enumer.hasMoreElements()) {
89
90
  var ctx = enumer.nextElement();
90
91
  if (ctx.getElapsedTime() > conf.profile_max_time) {
91
- //강제 종료된다.
92
- TraceContextManager.end(ctx._id);
92
+ //TraceContextManager.end(ctx._id);
93
+ var obj = TraceContextManager.resume(ctx._id);
94
+ TraceContextManager.addStep("Lost Connection","");
95
+ //ctx.status = 5;
96
+ //ctx.error = StatError.addError(500, "Lost Connection", ctx.service_hash);
97
+ TraceContextManager.endTrace(ctx);
93
98
  }
94
99
  }
95
100
 
@@ -41,15 +41,8 @@ SystemKubeTask.prototype.process = function (p) {
41
41
  p.cpu_cores = 1; // static one core in nodejs
42
42
  p.host_ip = SecurityMaster.IP;
43
43
  var now = Date.now();
44
-
45
- if (now < KubeClient.node_recv_time + 10000) {
46
- // 몽땅 만들어야 함.
47
- p.cpu = KubeClient.cpu * ConfSysMon.correction_factor_cpu;
48
- p.mem = KubeClient.memory * ConfSysMon.correction_factor_pcpu;
49
- // p.metering = KubeClient.metering == 0 ? p.cpu_cores : KubeClient.metering;
50
- p.metering = 1;
51
- }
52
-
44
+ p.cpu = 0;
45
+ p.mem = 0;
53
46
  if (p.metering != 0) {
54
47
  this.last_metering = p.metering;
55
48
  } else {
@@ -6,6 +6,7 @@
6
6
 
7
7
  var CounterTask = require('./counter-task'),
8
8
  ResourceProfile = require('./../../util/resourceprofile'),
9
+ KubeUtil = require('./../../util/kube-util'),
9
10
  SecurityMaster = require('../../net/security-master');
10
11
 
11
12
  function SystemPerf(){
@@ -25,10 +26,18 @@ SystemPerf.prototype.process = function(p) {
25
26
  p.cpu_proc = cpu.proc;
26
27
 
27
28
  p.disk = ResourceProfile.getDisk().usage;
28
- p.mem = ResourceProfile.getMemory().usage;
29
+
30
+ if(p.version <= 1) p.mem = ResourceProfile.getMemory().usage;
31
+ else p.mem = ResourceProfile.getMemoryV2().usage;
32
+
29
33
  p.cpu_cores = cpu.core;
30
34
  p.host_ip = SecurityMaster.IP;
31
35
  p.pid=process.pid;
36
+
37
+ if (KubeUtil.container_id != null) {
38
+ p.mem = 0;
39
+ p.cpu = 0;
40
+ }
32
41
  };
33
42
 
34
43
  module.exports = SystemPerf;
@@ -34,24 +34,29 @@ ScheduleObserver.prototype.inject = function (mod, moduleName) {
34
34
  var orig = ret.job;
35
35
  if(!orig) return;
36
36
  ret.job = async () => {
37
- var ctx = TraceContextManager.startTrace('ScheduleJob');
37
+ var ctx = null;
38
+ if(conf['trace_node_schedule_enabled']) {
39
+ ctx = TraceContextManager.startTrace('ScheduleJob');
40
+ }
38
41
  var result = null;
39
42
  try {
40
43
  result = await orig.apply(this, arguments);
41
44
  } catch(err) {
42
45
  Logger.printError('WHATAP-607', 'End batch error..', err, false);
43
46
  }
44
- try {
45
- var step = new MessageStep();
46
- step.msg = 'Node ScheduleJob finished!!!!!'
47
- step.hash = HashUtil.hashFromString(step.msg);;
48
- step.start_time = ctx.getElapsedTime();
49
- step.desc = '';
50
- DataTextAgent.MESSAGE.add(step.hash, step.msg);
51
- ctx.profile.add(step);
52
- TraceContextManager.endTrace(ctx);
53
- if(ctx != null) ctx = null;
54
- } catch(err) {}
47
+ if(conf['trace_node_schedule_enabled'] && ctx != null) {
48
+ try {
49
+ var step = new MessageStep();
50
+ step.msg = 'Node ScheduleJob finished!!!!!'
51
+ step.hash = HashUtil.hashFromString(step.msg);;
52
+ step.start_time = ctx.getElapsedTime();
53
+ step.desc = '';
54
+ DataTextAgent.MESSAGE.add(step.hash, step.msg);
55
+ ctx.profile.add(step);
56
+ TraceContextManager.endTrace(ctx);
57
+ if(ctx != null) ctx = null;
58
+ } catch(err) {}
59
+ }
55
60
  return result;
56
61
  };
57
62
  }
@@ -18,13 +18,14 @@ var KubeUtil = {
18
18
  var line = contents[i];
19
19
  if(line){
20
20
  this.container_id = line.substr(line.lastIndexOf('/')+1) || '';
21
- this.container_id = this.container_id.replace(/^(docker-)+|(\\.scope)+$/ig, "");
21
+ this.container_id = this.container_id.replace(/^(docker-)+|(containerd-)+|(crio-)+|(\\.scope)+$/ig, "");
22
22
  if(this.container_id.length > 5){
23
23
  this.container_key = HashUtil.hash(this.container_id);
24
24
  break;
25
25
  }
26
26
  }
27
27
  }
28
+ Logger.print('WHATAP-800' , 'id:' + this.container_id + ' // key:' + this.container_key , false)
28
29
  }catch(e){
29
30
  Logger.printError('WHATAP-800', 'KubeUtil(loadContainerId) ', e)
30
31
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "whatap",
3
3
  "homepage": "http://www.whatap.io",
4
- "version": "0.4.44",
5
- "releaseDate": "20220204",
4
+ "version": "0.4.47",
5
+ "releaseDate": "20220602",
6
6
  "description": "Monitoring and Profiling Service",
7
7
  "main": "index.js",
8
8
  "scripts": {},