@interopio/otel 0.0.42 → 0.0.43

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.
@@ -1,12 +1,12 @@
1
1
  import { Meter, ObservableResult } from "@opentelemetry/api";
2
2
  import { ApplicationMetricData, InternalMetricSettings } from "../base/types";
3
- import { GaugeMetricBase } from "../base/gauge";
4
3
  import { Logger } from "../../../logger/types";
5
- import { PerformanceProvider } from "../../dependencies/types";
6
- export declare class ApplicationCPUMetric extends GaugeMetricBase<ApplicationMetricData> {
4
+ import { AppCPU, PerformanceProvider } from "../../dependencies/types";
5
+ import { ZeroOutOnClosedAppGaugeMetric } from "./zeroOutOnClosedAppGaugeMetric";
6
+ export declare class ApplicationCPUMetric extends ZeroOutOnClosedAppGaugeMetric {
7
7
  perfProvider: PerformanceProvider;
8
8
  constructor(settings: InternalMetricSettings, meter: Meter, logger: Logger, perfProvider: PerformanceProvider);
9
9
  protected subscribeCore(): Promise<void>;
10
- protected observeCore(result: ObservableResult<ApplicationMetricData>): Promise<void>;
10
+ protected observeCoreCore(result: ObservableResult<ApplicationMetricData>): Promise<AppCPU[]>;
11
11
  protected unsubscribeCore(): Promise<void>;
12
12
  }
@@ -10,16 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ApplicationCPUMetric = void 0;
13
- const gauge_1 = require("../base/gauge");
14
13
  const perf_1 = require("../../../validation/metrics/perf");
15
14
  const validator_1 = require("../../../validation/validator");
16
- class ApplicationCPUMetric extends gauge_1.GaugeMetricBase {
15
+ const zeroOutOnClosedAppGaugeMetric_1 = require("./zeroOutOnClosedAppGaugeMetric");
16
+ class ApplicationCPUMetric extends zeroOutOnClosedAppGaugeMetric_1.ZeroOutOnClosedAppGaugeMetric {
17
17
  constructor(settings, meter, logger, perfProvider) {
18
18
  super(settings, meter, logger);
19
19
  this.perfProvider = perfProvider;
20
20
  }
21
21
  subscribeCore() { return Promise.resolve(); }
22
- observeCore(result) {
22
+ observeCoreCore(result) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
24
  const performanceValidator = new perf_1.PerformanceProviderValidator();
25
25
  performanceValidator.validate(this.perfProvider);
@@ -31,7 +31,9 @@ class ApplicationCPUMetric extends gauge_1.GaugeMetricBase {
31
31
  result.observe(info.cpu, data);
32
32
  this.logger.debug(`metric ${this.settings.name} sent cpu ${info.cpu} for app ${data.application} and instance ${data.applicationInstance}`);
33
33
  });
34
+ return appsCPU;
34
35
  }
36
+ return [];
35
37
  });
36
38
  }
37
39
  unsubscribeCore() { return Promise.resolve(); }
@@ -1 +1 @@
1
- {"version":3,"file":"cpu.js","sourceRoot":"","sources":["../../../../src/metrics/metrics/application/cpu.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgD;AAChD,2DAAgF;AAChF,6DAA0D;AAI1D,MAAa,oBAAqB,SAAQ,uBAAsC;IAC5E,YACI,QAAgC,EAChC,KAAY,EACZ,MAAc,EACP,YAAiC;QAExC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAFxB,iBAAY,GAAZ,YAAY,CAAqB;IAG5C,CAAC;IAEkB,aAAa,KAAoB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAEtD,WAAW,CAAC,MAA+C;;YAChF,MAAM,oBAAoB,GAAG,IAAI,mCAA4B,EAAE,CAAC;YAChE,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAEjD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;YACrD,IAAI,CAAC,qBAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE;gBACvC,oBAAoB,CAAC,eAAe,CAAC,OAAQ,CAAC,CAAC;gBAE/C,OAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAA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AC,eAAe,CAAC,OAAQ,CAAC,CAAC;gBAE/C,OAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACtB,MAAM,IAAI,mBAAK,mBAAmB,EAAE,IAAI,CAAC,QAAQ,IAAK,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,CAAC;oBAC1F,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,aAAa,IAAI,CAAC,GAAG,YAAY,IAAI,CAAC,WAAW,iBAAiB,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;gBAChJ,CAAC,CAAC,CAAC;gBACH,OAAO,OAAQ,CAAC;aACnB;YACD,OAAO,EAAE,CAAC;QACd,CAAC;KAAA;IAEkB,eAAe,KAAoB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACpF;AA/BD,oDA+BC"}
@@ -1,13 +1,13 @@
1
1
  import { Meter, ObservableResult } from "@opentelemetry/api";
2
2
  import { ApplicationMetricData, InternalMetricSettings } from "../base/types";
3
- import { GaugeMetricBase } from "../base/gauge";
4
3
  import { Logger } from "../../../logger/types";
5
- import { PerformanceProvider } from "../../dependencies/types";
6
- export declare class ApplicationMemoryMetric extends GaugeMetricBase<ApplicationMetricData> {
4
+ import { AppMemory, PerformanceProvider } from "../../dependencies/types";
5
+ import { ZeroOutOnClosedAppGaugeMetric } from "./zeroOutOnClosedAppGaugeMetric";
6
+ export declare class ApplicationMemoryMetric extends ZeroOutOnClosedAppGaugeMetric {
7
7
  perfProvider: PerformanceProvider;
8
8
  private validator;
9
9
  constructor(settings: InternalMetricSettings, meter: Meter, logger: Logger, perfProvider: PerformanceProvider);
10
10
  protected subscribeCore(): Promise<void>;
11
- protected observeCore(result: ObservableResult<ApplicationMetricData>): Promise<void>;
11
+ protected observeCoreCore(result: ObservableResult<ApplicationMetricData>): Promise<AppMemory[]>;
12
12
  protected unsubscribeCore(): Promise<void>;
13
13
  }
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ApplicationMemoryMetric = void 0;
13
- const gauge_1 = require("../base/gauge");
14
13
  const perf_1 = require("../../../validation/metrics/perf");
15
14
  const validator_1 = require("../../../validation/validator");
16
- class ApplicationMemoryMetric extends gauge_1.GaugeMetricBase {
15
+ const zeroOutOnClosedAppGaugeMetric_1 = require("./zeroOutOnClosedAppGaugeMetric");
16
+ class ApplicationMemoryMetric extends zeroOutOnClosedAppGaugeMetric_1.ZeroOutOnClosedAppGaugeMetric {
17
17
  constructor(settings, meter, logger, perfProvider) {
18
18
  super(settings, meter, logger);
19
19
  this.perfProvider = perfProvider;
@@ -21,7 +21,7 @@ class ApplicationMemoryMetric extends gauge_1.GaugeMetricBase {
21
21
  this.validator.validate(this.perfProvider);
22
22
  }
23
23
  subscribeCore() { return Promise.resolve(); }
24
- observeCore(result) {
24
+ observeCoreCore(result) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
26
  const appsMemory = yield this.perfProvider.getAppsMemory();
27
27
  if (!validator_1.Validator.isNullOrUndefined(appsMemory)) {
@@ -32,6 +32,10 @@ class ApplicationMemoryMetric extends gauge_1.GaugeMetricBase {
32
32
  result.observe((_a = info.memory) !== null && _a !== void 0 ? _a : 0, data);
33
33
  this.logger.debug(`metric ${this.settings.name} sent memory ${info.memory} for app ${data.application} and instance ${data.applicationInstance}`);
34
34
  });
35
+ return appsMemory;
36
+ }
37
+ else {
38
+ return [];
35
39
  }
36
40
  });
37
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../src/metrics/metrics/application/memory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgD;AAChD,2DAAgF;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C,CAAC;gBACH,OAAO,UAAW,CAAC;aACtB;iBACI;gBACD,OAAO,EAAE,CAAC;aACb;QACL,CAAC;KAAA;IAEkB,eAAe,KAAoB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CACpF;AAnCD,0DAmCC"}
@@ -0,0 +1,11 @@
1
+ import { ObservableResult } from "@opentelemetry/api";
2
+ import { ApplicationMetricData } from "../base/types";
3
+ import { GaugeMetricBase } from "../base/gauge";
4
+ export declare abstract class ZeroOutOnClosedAppGaugeMetric extends GaugeMetricBase<ApplicationMetricData> {
5
+ private reported?;
6
+ protected abstract observeCoreCore(result: ObservableResult<ApplicationMetricData>): Promise<{
7
+ instance: string;
8
+ app: string;
9
+ }[]>;
10
+ protected observeCore(result: ObservableResult<ApplicationMetricData>): Promise<void>;
11
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ZeroOutOnClosedAppGaugeMetric = void 0;
13
+ const gauge_1 = require("../base/gauge");
14
+ class ZeroOutOnClosedAppGaugeMetric extends gauge_1.GaugeMetricBase {
15
+ observeCore(result) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const apps = yield this.observeCoreCore(result);
18
+ if (this.reported) {
19
+ for (const closed of this.reported.filter(x => !apps.some(y => x.instance === y.instance))) {
20
+ const data = Object.assign({ applicationInstance: closed.instance }, this.getApplicationData(closed.app));
21
+ result.observe(0, data);
22
+ this.logger.debug(`metric ${this.settings.name} sent 0 for closed app ${data.application} and instance ${data.applicationInstance}`);
23
+ }
24
+ }
25
+ this.reported = apps;
26
+ });
27
+ }
28
+ }
29
+ exports.ZeroOutOnClosedAppGaugeMetric = ZeroOutOnClosedAppGaugeMetric;
30
+ //# sourceMappingURL=zeroOutOnClosedAppGaugeMetric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zeroOutOnClosedAppGaugeMetric.js","sourceRoot":"","sources":["../../../../src/metrics/metrics/application/zeroOutOnClosedAppGaugeMetric.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgD;AAGhD,MAAsB,6BAA8B,SAAQ,uBAAsC;IAMrE,WAAW,CAAC,MAA+C;;YAChF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAChD,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACzF,MAAM,IAAI,mBAAK,mBAAmB,EAAE,MAAM,CAAC,QAAQ,IAAK,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,CAAC;oBAC9F,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,0BAA0B,IAAI,CAAC,WAAW,iBAAiB,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;iBACxI;aACJ;YACD,IAAI,CAAC,QAAQ,GAAG,IAAK,CAAC;QAC1B,CAAC;KAAA;CACJ;AAjBD,sEAiBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/otel",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "otel library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",