@sesamecare-oss/opentelemetry-node-metrics 1.1.0 → 2.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.
- package/README.md +2 -2
- package/build/helpers/counterNames.d.ts +1 -1
- package/build/helpers/counterNames.js +1 -4
- package/build/helpers/counterNames.js.map +1 -1
- package/build/helpers/processMetricsHelpers.d.ts +1 -1
- package/build/helpers/processMetricsHelpers.js +1 -4
- package/build/helpers/processMetricsHelpers.js.map +1 -1
- package/build/helpers/safeMemoryUsage.js +1 -4
- package/build/helpers/safeMemoryUsage.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +4 -34
- package/build/index.js.map +1 -1
- package/build/metrics/eventLoopLag.d.ts +2 -2
- package/build/metrics/eventLoopLag.js +11 -17
- package/build/metrics/eventLoopLag.js.map +1 -1
- package/build/metrics/gc.d.ts +2 -2
- package/build/metrics/gc.js +10 -13
- package/build/metrics/gc.js.map +1 -1
- package/build/metrics/heapSizeAndUsed.d.ts +2 -2
- package/build/metrics/heapSizeAndUsed.js +9 -11
- package/build/metrics/heapSizeAndUsed.js.map +1 -1
- package/build/metrics/heapSpacesSizeAndUsed.d.ts +2 -2
- package/build/metrics/heapSpacesSizeAndUsed.js +7 -13
- package/build/metrics/heapSpacesSizeAndUsed.js.map +1 -1
- package/build/metrics/index.js +10 -26
- package/build/metrics/index.js.map +1 -1
- package/build/metrics/osMemoryHeap.d.ts +2 -2
- package/build/metrics/osMemoryHeap.js +8 -11
- package/build/metrics/osMemoryHeap.js.map +1 -1
- package/build/metrics/osMemoryHeapLinux.d.ts +2 -2
- package/build/metrics/osMemoryHeapLinux.js +9 -14
- package/build/metrics/osMemoryHeapLinux.js.map +1 -1
- package/build/metrics/processCpuTotal.d.ts +2 -2
- package/build/metrics/processCpuTotal.js +5 -8
- package/build/metrics/processCpuTotal.js.map +1 -1
- package/build/metrics/processMaxFileDescriptors.d.ts +2 -2
- package/build/metrics/processMaxFileDescriptors.js +5 -11
- package/build/metrics/processMaxFileDescriptors.js.map +1 -1
- package/build/metrics/processOpenFileDescriptors.d.ts +2 -2
- package/build/metrics/processOpenFileDescriptors.js +8 -13
- package/build/metrics/processOpenFileDescriptors.js.map +1 -1
- package/build/metrics/processResources.d.ts +2 -2
- package/build/metrics/processResources.js +8 -14
- package/build/metrics/processResources.js.map +1 -1
- package/build/metrics/processStartTime.d.ts +2 -2
- package/build/metrics/processStartTime.js +3 -6
- package/build/metrics/processStartTime.js.map +1 -1
- package/build/metrics/version.d.ts +2 -2
- package/build/metrics/version.js +3 -6
- package/build/metrics/version.js.map +1 -1
- package/build/types.js +0 -2
- package/package.json +20 -18
- package/src/helpers/counterNames.ts +1 -1
- package/src/helpers/processMetricsHelpers.ts +3 -3
- package/src/index.spec.ts +13 -0
- package/src/index.ts +2 -2
- package/src/metrics/eventLoopLag.ts +2 -2
- package/src/metrics/gc.ts +11 -6
- package/src/metrics/heapSizeAndUsed.ts +3 -3
- package/src/metrics/heapSpacesSizeAndUsed.ts +2 -2
- package/src/metrics/osMemoryHeap.ts +2 -2
- package/src/metrics/osMemoryHeapLinux.ts +3 -3
- package/src/metrics/processCpuTotal.ts +2 -2
- package/src/metrics/processMaxFileDescriptors.ts +2 -2
- package/src/metrics/processOpenFileDescriptors.ts +3 -3
- package/src/metrics/processResources.ts +2 -2
- package/src/metrics/processStartTime.ts +2 -2
- package/src/metrics/version.ts +2 -2
- package/.commitlintrc.json +0 -5
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -14
- package/.github/workflows/nodejs.yml +0 -58
- package/.prettierrc.js +0 -14
- package/.trunk/configs/.markdownlint.yaml +0 -10
- package/.trunk/configs/.yamllint.yaml +0 -10
- package/.trunk/trunk.yaml +0 -37
- package/.vscode/metrics.code-snippets +0 -13
- package/CHANGELOG.md +0 -15
- package/build/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -44
- package/vitest.config.ts +0 -19
package/README.md
CHANGED
|
@@ -21,6 +21,6 @@ const meter = metrics.getMeterProvider().getMeter('node-metrics');
|
|
|
21
21
|
setupNodeMetrics(meter);
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Now your Prometheus-exported metrics should be included along with whatever other metrics you
|
|
24
|
+
Now your Prometheus-exported metrics should be included along with whatever other metrics you have selected. See [openapi-typescript-infra/service](https://github.com/openapi-typescript-infra/service) for a more complete example of metrics integrated with an express service host.
|
|
25
25
|
|
|
26
|
-
One notable change from the existing libraries - they divide active handles and active 'requests' using deprecated Node APIs. I've
|
|
26
|
+
One notable change from the existing libraries - they divide active handles and active 'requests' using deprecated Node APIs. I've chosen to merge these into 'resources' using the new getActiveResourcesInfo API, which is Node17+. It should fail gracefully if that function is not available.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { NodeMetricConfig } from '../types';
|
|
2
2
|
export declare function prefixedName(config: NodeMetricConfig | undefined, name: string): string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prefixedName = prefixedName;
|
|
4
|
-
function prefixedName(config, name) {
|
|
1
|
+
export function prefixedName(config, name) {
|
|
5
2
|
return `${config?.prefix || ''}${name}`;
|
|
6
3
|
}
|
|
7
4
|
//# sourceMappingURL=counterNames.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterNames.js","sourceRoot":"","sources":["../../src/helpers/counterNames.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"counterNames.js","sourceRoot":"","sources":["../../src/helpers/counterNames.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,MAAoC,EAAE,IAAY;IAC7E,OAAO,GAAG,MAAM,EAAE,MAAM,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Attributes, ObservableResult } from '@opentelemetry/api';
|
|
1
|
+
import type { Attributes, ObservableResult } from '@opentelemetry/api';
|
|
2
2
|
export declare function createAggregatorByObjectName(): (metric: ObservableResult<Attributes>, labels: Record<string, string> | undefined, list: string[]) => void;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAggregatorByObjectName = createAggregatorByObjectName;
|
|
4
|
-
function createAggregatorByObjectName() {
|
|
1
|
+
export function createAggregatorByObjectName() {
|
|
5
2
|
const all = new Map();
|
|
6
3
|
return function aggregateByObjectName(metric, labels, list) {
|
|
7
4
|
const current = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processMetricsHelpers.js","sourceRoot":"","sources":["../../src/helpers/processMetricsHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processMetricsHelpers.js","sourceRoot":"","sources":["../../src/helpers/processMetricsHelpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkC,CAAC;IACtD,OAAO,SAAS,qBAAqB,CACnC,MAAoC,EACpC,MAA0C,EAC1C,IAAc;QAEd,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACtB,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;YAC9D,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YACpC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeMemoryUsage.js","sourceRoot":"","sources":["../../src/helpers/safeMemoryUsage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"safeMemoryUsage.js","sourceRoot":"","sources":["../../src/helpers/safeMemoryUsage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,qBAAqB;IACvB,CAAC;AACH,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
2
|
import * as metrics from './metrics';
|
|
3
|
-
import { NodeMetricConfig } from './types';
|
|
3
|
+
import type { NodeMetricConfig } from './types';
|
|
4
4
|
export declare function setupNodeMetrics(meter: Meter, config?: NodeMetricConfig): void;
|
|
5
5
|
export * from './types';
|
|
6
6
|
export declare const NodeMetrics: typeof metrics;
|
package/build/index.js
CHANGED
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.NodeMetrics = void 0;
|
|
30
|
-
exports.setupNodeMetrics = setupNodeMetrics;
|
|
31
|
-
const metrics = __importStar(require("./metrics"));
|
|
32
|
-
function setupNodeMetrics(meter, config) {
|
|
1
|
+
import * as metrics from './metrics';
|
|
2
|
+
export function setupNodeMetrics(meter, config) {
|
|
33
3
|
Object.values(metrics).forEach((metric) => {
|
|
34
4
|
metric(meter, config);
|
|
35
5
|
});
|
|
36
6
|
}
|
|
37
|
-
|
|
38
|
-
|
|
7
|
+
export * from './types';
|
|
8
|
+
export const NodeMetrics = metrics;
|
|
39
9
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,MAAM,UAAU,gBAAgB,CAAC,KAAY,EAAE,MAAyB;IACtE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACxC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function eventLoopLagMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace eventLoopLagMetric {
|
|
5
5
|
var metricNames: string[];
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.eventLoopLagMetric = eventLoopLagMetric;
|
|
7
|
-
const perf_hooks_1 = __importDefault(require("perf_hooks"));
|
|
8
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
1
|
+
import perfHooks from 'perf_hooks';
|
|
2
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
9
3
|
// Reported always.
|
|
10
4
|
const NODEJS_EVENTLOOP_LAG = 'nodejs_eventloop_lag_seconds';
|
|
11
5
|
// Reported only when perf_hooks is available.
|
|
@@ -16,55 +10,55 @@ const NODEJS_EVENTLOOP_LAG_STDDEV = 'nodejs_eventloop_lag_stddev_seconds';
|
|
|
16
10
|
const NODEJS_EVENTLOOP_LAG_P50 = 'nodejs_eventloop_lag_p50_seconds';
|
|
17
11
|
const NODEJS_EVENTLOOP_LAG_P90 = 'nodejs_eventloop_lag_p90_seconds';
|
|
18
12
|
const NODEJS_EVENTLOOP_LAG_P99 = 'nodejs_eventloop_lag_p99_seconds';
|
|
19
|
-
function eventLoopLagMetric(meter, config) {
|
|
20
|
-
const histogram =
|
|
13
|
+
export function eventLoopLagMetric(meter, config) {
|
|
14
|
+
const histogram = perfHooks.monitorEventLoopDelay({
|
|
21
15
|
resolution: config?.eventLoopMonitoringPrecision,
|
|
22
16
|
});
|
|
23
17
|
histogram.enable();
|
|
24
18
|
meter
|
|
25
|
-
.createObservableGauge(
|
|
19
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_MIN), {
|
|
26
20
|
description: 'The minimum recorded event loop delay.',
|
|
27
21
|
})
|
|
28
22
|
.addCallback((observable) => {
|
|
29
23
|
observable.observe(histogram.min / 1e9, config?.labels);
|
|
30
24
|
});
|
|
31
25
|
meter
|
|
32
|
-
.createObservableGauge(
|
|
26
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_MAX), {
|
|
33
27
|
description: 'The maximum recorded event loop delay.',
|
|
34
28
|
})
|
|
35
29
|
.addCallback((observable) => {
|
|
36
30
|
observable.observe(histogram.max / 1e9, config?.labels);
|
|
37
31
|
});
|
|
38
32
|
meter
|
|
39
|
-
.createObservableGauge(
|
|
33
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_MEAN), {
|
|
40
34
|
description: 'The mean of the recorded event loop delays.',
|
|
41
35
|
})
|
|
42
36
|
.addCallback((observable) => {
|
|
43
37
|
observable.observe(histogram.mean / 1e9, config?.labels);
|
|
44
38
|
});
|
|
45
39
|
meter
|
|
46
|
-
.createObservableGauge(
|
|
40
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_STDDEV), {
|
|
47
41
|
description: 'The standard deviation of the recorded event loop delays.',
|
|
48
42
|
})
|
|
49
43
|
.addCallback((observable) => {
|
|
50
44
|
observable.observe(histogram.stddev / 1e9, config?.labels);
|
|
51
45
|
});
|
|
52
46
|
meter
|
|
53
|
-
.createObservableGauge(
|
|
47
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_P50), {
|
|
54
48
|
description: 'The 50th percentile of the recorded event loop delays.',
|
|
55
49
|
})
|
|
56
50
|
.addCallback((observable) => {
|
|
57
51
|
observable.observe(histogram.percentile(50) / 1e9, config?.labels);
|
|
58
52
|
});
|
|
59
53
|
meter
|
|
60
|
-
.createObservableGauge(
|
|
54
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_P90), {
|
|
61
55
|
description: 'The 90th percentile of the recorded event loop delays.',
|
|
62
56
|
})
|
|
63
57
|
.addCallback((observable) => {
|
|
64
58
|
observable.observe(histogram.percentile(90) / 1e9, config?.labels);
|
|
65
59
|
});
|
|
66
60
|
meter
|
|
67
|
-
.createObservableGauge(
|
|
61
|
+
.createObservableGauge(prefixedName(config, NODEJS_EVENTLOOP_LAG_P99), {
|
|
68
62
|
description: 'The 99th percentile of the recorded event loop delays.',
|
|
69
63
|
})
|
|
70
64
|
.addCallback((observable) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventLoopLag.js","sourceRoot":"","sources":["../../src/metrics/eventLoopLag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventLoopLag.js","sourceRoot":"","sources":["../../src/metrics/eventLoopLag.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAKnC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,mBAAmB;AACnB,MAAM,oBAAoB,GAAG,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,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,kBAAkB,CAAC,WAAW,GAAG;IAC/B,oBAAoB;IACpB,wBAAwB;IACxB,wBAAwB;IACxB,yBAAyB;IACzB,2BAA2B;IAC3B,wBAAwB;IACxB,wBAAwB;IACxB,wBAAwB;CACzB,CAAC"}
|
package/build/metrics/gc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function gcMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace gcMetric {
|
|
5
5
|
var metricNames: string[];
|
package/build/metrics/gc.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.gcMetric = gcMetric;
|
|
4
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
5
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
1
|
+
import { PerformanceObserver, constants } from 'perf_hooks';
|
|
2
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
6
3
|
const NODEJS_GC_DURATION_SECONDS = 'nodejs_gc_duration_seconds';
|
|
7
4
|
function keyForDetail(detail) {
|
|
8
5
|
if (typeof detail === 'object' && detail !== null && 'kind' in detail) {
|
|
9
|
-
return detail.kind
|
|
6
|
+
return detail.kind ?? 'other';
|
|
10
7
|
}
|
|
11
8
|
return 'other';
|
|
12
9
|
}
|
|
13
|
-
function gcMetric(meter, config) {
|
|
14
|
-
const histogram = meter.createHistogram(
|
|
10
|
+
export function gcMetric(meter, config) {
|
|
11
|
+
const histogram = meter.createHistogram(prefixedName(config, NODEJS_GC_DURATION_SECONDS), {
|
|
15
12
|
description: 'Garbage collection duration by kind, one of major, minor, incremental or weakcb.',
|
|
16
13
|
});
|
|
17
14
|
const kinds = {};
|
|
18
|
-
kinds[
|
|
19
|
-
kinds[
|
|
20
|
-
kinds[
|
|
21
|
-
kinds[
|
|
15
|
+
kinds[constants.NODE_PERFORMANCE_GC_MAJOR] = { ...config?.labels, kind: 'major' };
|
|
16
|
+
kinds[constants.NODE_PERFORMANCE_GC_MINOR] = { ...config?.labels, kind: 'minor' };
|
|
17
|
+
kinds[constants.NODE_PERFORMANCE_GC_INCREMENTAL] = { ...config?.labels, kind: 'incremental' };
|
|
18
|
+
kinds[constants.NODE_PERFORMANCE_GC_WEAKCB] = { ...config?.labels, kind: 'weakcb' };
|
|
22
19
|
kinds['other'] = { ...config?.labels, kind: 'other' };
|
|
23
|
-
const obs = new
|
|
20
|
+
const obs = new PerformanceObserver((list) => {
|
|
24
21
|
const entry = list.getEntries()[0];
|
|
25
22
|
// Convert duration from milliseconds to seconds
|
|
26
23
|
histogram.record(entry.duration / 1000, kinds[keyForDetail(entry.detail)]);
|
package/build/metrics/gc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gc.js","sourceRoot":"","sources":["../../src/metrics/gc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gc.js","sourceRoot":"","sources":["../../src/metrics/gc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,0BAA0B,GAAG,4BAA4B,CAAC;AAMhE,SAAS,YAAY,CAAC,MAAe;IACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACtE,OAAQ,MAAmB,CAAC,IAAI,IAAI,OAAO,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY,EAAE,MAAy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AG,CAAC,0BAA0B,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function heapSizeAndUsedMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace heapSizeAndUsedMetric {
|
|
5
5
|
var metricNames: string[];
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.heapSizeAndUsedMetric = heapSizeAndUsedMetric;
|
|
4
|
-
const safeMemoryUsage_1 = require("../helpers/safeMemoryUsage");
|
|
5
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
1
|
+
import { safeMemoryUsage } from '../helpers/safeMemoryUsage';
|
|
2
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
6
3
|
const NODEJS_HEAP_SIZE_TOTAL = 'nodejs_heap_size_total_bytes';
|
|
7
4
|
const NODEJS_HEAP_SIZE_USED = 'nodejs_heap_size_used_bytes';
|
|
8
5
|
const NODEJS_EXTERNAL_MEMORY = 'nodejs_external_memory_bytes';
|
|
9
|
-
function heapSizeAndUsedMetric(meter, config) {
|
|
6
|
+
export function heapSizeAndUsedMetric(meter, config) {
|
|
10
7
|
let stats;
|
|
11
8
|
function getStats() {
|
|
12
|
-
if (stats !== undefined)
|
|
9
|
+
if (stats !== undefined) {
|
|
13
10
|
return stats;
|
|
14
|
-
|
|
11
|
+
}
|
|
12
|
+
stats = safeMemoryUsage() || false;
|
|
15
13
|
setTimeout(() => {
|
|
16
14
|
stats = undefined;
|
|
17
15
|
}, 1000).unref();
|
|
18
16
|
return stats;
|
|
19
17
|
}
|
|
20
18
|
meter
|
|
21
|
-
.createObservableGauge(
|
|
19
|
+
.createObservableGauge(prefixedName(config, NODEJS_HEAP_SIZE_TOTAL), {
|
|
22
20
|
description: 'Process heap size from Node.js in bytes.',
|
|
23
21
|
})
|
|
24
22
|
.addCallback((observable) => {
|
|
@@ -28,7 +26,7 @@ function heapSizeAndUsedMetric(meter, config) {
|
|
|
28
26
|
observable.observe(stats.heapTotal, config?.labels);
|
|
29
27
|
});
|
|
30
28
|
meter
|
|
31
|
-
.createObservableGauge(
|
|
29
|
+
.createObservableGauge(prefixedName(config, NODEJS_HEAP_SIZE_USED), {
|
|
32
30
|
description: 'Process heap size used from Node.js in bytes.',
|
|
33
31
|
})
|
|
34
32
|
.addCallback((observable) => {
|
|
@@ -38,7 +36,7 @@ function heapSizeAndUsedMetric(meter, config) {
|
|
|
38
36
|
observable.observe(stats.heapUsed, config?.labels);
|
|
39
37
|
});
|
|
40
38
|
meter
|
|
41
|
-
.createObservableGauge(
|
|
39
|
+
.createObservableGauge(prefixedName(config, NODEJS_EXTERNAL_MEMORY), {
|
|
42
40
|
description: 'Node.js external memory size in bytes.',
|
|
43
41
|
})
|
|
44
42
|
.addCallback((observable) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heapSizeAndUsed.js","sourceRoot":"","sources":["../../src/metrics/heapSizeAndUsed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"heapSizeAndUsed.js","sourceRoot":"","sources":["../../src/metrics/heapSizeAndUsed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAC9D,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAC5D,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAE9D,MAAM,UAAU,qBAAqB,CAAC,KAAY,EAAE,MAAyB;IAC3E,IAAI,KAA6D,CAAC;IAElE,SAAS,QAAQ;QACf,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAAA,OAAO,KA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AC;QACD,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,qBAAqB,CAAC,WAAW,GAAG;IAClC,sBAAsB;IACtB,qBAAqB;IACrB,sBAAsB;CACvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function heapSpacesSizeAndUsedMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace heapSpacesSizeAndUsedMetric {
|
|
5
5
|
var metricNames: string[];
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.heapSpacesSizeAndUsedMetric = heapSpacesSizeAndUsedMetric;
|
|
7
|
-
const v8_1 = __importDefault(require("v8"));
|
|
8
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
1
|
+
import v8 from 'v8';
|
|
2
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
9
3
|
const METRICS = ['total', 'used', 'available'];
|
|
10
4
|
const NODEJS_HEAP_SIZE = {};
|
|
11
5
|
for (const metricType of METRICS) {
|
|
12
6
|
NODEJS_HEAP_SIZE[metricType] = `nodejs_heap_space_size_${metricType}_bytes`;
|
|
13
7
|
}
|
|
14
|
-
function heapSpacesSizeAndUsedMetric(meter, config) {
|
|
8
|
+
export function heapSpacesSizeAndUsedMetric(meter, config) {
|
|
15
9
|
const labelsBySpace = {};
|
|
16
10
|
let stats;
|
|
17
11
|
function getStats() {
|
|
18
12
|
if (stats !== undefined) {
|
|
19
13
|
return stats;
|
|
20
14
|
}
|
|
21
|
-
stats =
|
|
15
|
+
stats = v8.getHeapSpaceStatistics().map((space) => {
|
|
22
16
|
const spaceLabels = labelsBySpace[space.space_name] ||
|
|
23
17
|
(function () {
|
|
24
18
|
const spaceName = space.space_name.replace(/_space$/, '');
|
|
@@ -41,7 +35,7 @@ function heapSpacesSizeAndUsedMetric(meter, config) {
|
|
|
41
35
|
return stats;
|
|
42
36
|
}
|
|
43
37
|
meter
|
|
44
|
-
.createObservableGauge(
|
|
38
|
+
.createObservableGauge(prefixedName(config, NODEJS_HEAP_SIZE.total), {
|
|
45
39
|
description: 'Process heap space size total from Node.js in bytes.',
|
|
46
40
|
})
|
|
47
41
|
.addCallback((observable) => {
|
|
@@ -53,7 +47,7 @@ function heapSpacesSizeAndUsedMetric(meter, config) {
|
|
|
53
47
|
}
|
|
54
48
|
});
|
|
55
49
|
meter
|
|
56
|
-
.createObservableGauge(
|
|
50
|
+
.createObservableGauge(prefixedName(config, NODEJS_HEAP_SIZE.used), {
|
|
57
51
|
description: 'Process heap space size used from Node.js in bytes.',
|
|
58
52
|
})
|
|
59
53
|
.addCallback((observable) => {
|
|
@@ -65,7 +59,7 @@ function heapSpacesSizeAndUsedMetric(meter, config) {
|
|
|
65
59
|
}
|
|
66
60
|
});
|
|
67
61
|
meter
|
|
68
|
-
.createObservableGauge(
|
|
62
|
+
.createObservableGauge(prefixedName(config, NODEJS_HEAP_SIZE.available), {
|
|
69
63
|
description: 'Process heap space size available from Node.js in bytes.',
|
|
70
64
|
})
|
|
71
65
|
.addCallback((observable) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heapSpacesSizeAndUsed.js","sourceRoot":"","sources":["../../src/metrics/heapSpacesSizeAndUsed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"heapSpacesSizeAndUsed.js","sourceRoot":"","sources":["../../src/metrics/heapSpacesSizeAndUsed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM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,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,KAAK;SACF,qBAAqB,CAAC,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,EAAE;QACvE,WAAW,EAAE,0DAA0D;KACxE,CAAC;SACD,WAAW,CAAC,CAAC,UAAU,EAAE,EAAE;QAC1B,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO;QACT,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,2BAA2B,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
package/build/metrics/index.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./version"), exports);
|
|
18
|
-
__exportStar(require("./processStartTime"), exports);
|
|
19
|
-
__exportStar(require("./eventLoopLag"), exports);
|
|
20
|
-
__exportStar(require("./gc"), exports);
|
|
21
|
-
__exportStar(require("./heapSizeAndUsed"), exports);
|
|
22
|
-
__exportStar(require("./heapSpacesSizeAndUsed"), exports);
|
|
23
|
-
__exportStar(require("./osMemoryHeap"), exports);
|
|
24
|
-
__exportStar(require("./processCpuTotal"), exports);
|
|
25
|
-
__exportStar(require("./processResources"), exports);
|
|
26
|
-
__exportStar(require("./processMaxFileDescriptors"), exports);
|
|
1
|
+
export * from './version';
|
|
2
|
+
export * from './processStartTime';
|
|
3
|
+
export * from './eventLoopLag';
|
|
4
|
+
export * from './gc';
|
|
5
|
+
export * from './heapSizeAndUsed';
|
|
6
|
+
export * from './heapSpacesSizeAndUsed';
|
|
7
|
+
export * from './osMemoryHeap';
|
|
8
|
+
export * from './processCpuTotal';
|
|
9
|
+
export * from './processResources';
|
|
10
|
+
export * from './processMaxFileDescriptors';
|
|
27
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC;AACrB,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function osMemoryHeapMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace osMemoryHeapMetric {
|
|
5
5
|
var metricNames: string[];
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
5
|
-
const safeMemoryUsage_1 = require("../helpers/safeMemoryUsage");
|
|
6
|
-
const osMemoryHeapLinux_1 = require("./osMemoryHeapLinux");
|
|
1
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
2
|
+
import { safeMemoryUsage } from '../helpers/safeMemoryUsage';
|
|
3
|
+
import { osMemoryHeapLinuxMetric } from './osMemoryHeapLinux';
|
|
7
4
|
const PROCESS_RESIDENT_MEMORY = 'process_resident_memory_bytes';
|
|
8
|
-
function osMemoryHeapMetric(meter, config) {
|
|
5
|
+
export function osMemoryHeapMetric(meter, config) {
|
|
9
6
|
if (process.platform === 'linux') {
|
|
10
|
-
return
|
|
7
|
+
return osMemoryHeapLinuxMetric(meter, config);
|
|
11
8
|
}
|
|
12
9
|
meter
|
|
13
|
-
.createObservableGauge(
|
|
10
|
+
.createObservableGauge(prefixedName(config, PROCESS_RESIDENT_MEMORY), {
|
|
14
11
|
description: 'Resident memory size in bytes.',
|
|
15
12
|
})
|
|
16
13
|
.addCallback((observable) => {
|
|
17
|
-
const memUsage =
|
|
14
|
+
const memUsage = safeMemoryUsage();
|
|
18
15
|
// I don't think the other things returned from
|
|
19
16
|
// `process.memoryUsage()` is relevant to a standard export
|
|
20
17
|
if (memUsage) {
|
|
@@ -23,5 +20,5 @@ function osMemoryHeapMetric(meter, config) {
|
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
22
|
osMemoryHeapMetric.metricNames =
|
|
26
|
-
process.platform === 'linux' ?
|
|
23
|
+
process.platform === 'linux' ? osMemoryHeapLinuxMetric.metricNames : [PROCESS_RESIDENT_MEMORY];
|
|
27
24
|
//# sourceMappingURL=osMemoryHeap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"osMemoryHeap.js","sourceRoot":"","sources":["../../src/metrics/osMemoryHeap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"osMemoryHeap.js","sourceRoot":"","sources":["../../src/metrics/osMemoryHeap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAEhE,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,MAAyB;IACxE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,KAAK;SACF,qBAAqB,CAAC,YAAY,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAAE;QACpE,WAAW,EAAE,gCAAgC;KAC9C,CAAC;SACD,WAAW,CAAC,CAAC,UAAU,EAAE,EAAE;QAC1B,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;QACnC,+CAA+C;QAC/C,2DAA2D;QAC3D,IAAI,QAAQ,EAAE,CAAC;YACb,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,kBAAkB,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Meter } from '@opentelemetry/api';
|
|
2
|
-
import { NodeMetricConfig } from '../types';
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { NodeMetricConfig } from '../types';
|
|
3
3
|
export declare function osMemoryHeapLinuxMetric(meter: Meter, config?: NodeMetricConfig): void;
|
|
4
4
|
export declare namespace osMemoryHeapLinuxMetric {
|
|
5
5
|
var metricNames: string[];
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.osMemoryHeapLinuxMetric = osMemoryHeapLinuxMetric;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const counterNames_1 = require("../helpers/counterNames");
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { prefixedName } from '../helpers/counterNames';
|
|
9
3
|
const values = ['VmSize', 'VmRSS', 'VmData'];
|
|
10
4
|
const PROCESS_RESIDENT_MEMORY = 'process_resident_memory_bytes';
|
|
11
5
|
const PROCESS_VIRTUAL_MEMORY = 'process_virtual_memory_bytes';
|
|
@@ -27,13 +21,14 @@ function structureOutput(input) {
|
|
|
27
21
|
});
|
|
28
22
|
return returnValue;
|
|
29
23
|
}
|
|
30
|
-
function osMemoryHeapLinuxMetric(meter, config) {
|
|
24
|
+
export function osMemoryHeapLinuxMetric(meter, config) {
|
|
31
25
|
let stats;
|
|
32
26
|
function getStats() {
|
|
33
|
-
if (stats !== undefined)
|
|
27
|
+
if (stats !== undefined) {
|
|
34
28
|
return stats;
|
|
29
|
+
}
|
|
35
30
|
try {
|
|
36
|
-
const stat =
|
|
31
|
+
const stat = fs.readFileSync('/proc/self/status', 'utf8');
|
|
37
32
|
stats = structureOutput(stat);
|
|
38
33
|
}
|
|
39
34
|
catch {
|
|
@@ -45,7 +40,7 @@ function osMemoryHeapLinuxMetric(meter, config) {
|
|
|
45
40
|
return stats;
|
|
46
41
|
}
|
|
47
42
|
meter
|
|
48
|
-
.createObservableGauge(
|
|
43
|
+
.createObservableGauge(prefixedName(config, PROCESS_RESIDENT_MEMORY), {
|
|
49
44
|
description: 'Resident memory size in bytes.',
|
|
50
45
|
})
|
|
51
46
|
.addCallback((observable) => {
|
|
@@ -55,7 +50,7 @@ function osMemoryHeapLinuxMetric(meter, config) {
|
|
|
55
50
|
observable.observe(stats.VmRSS, config?.labels);
|
|
56
51
|
});
|
|
57
52
|
meter
|
|
58
|
-
.createObservableGauge(
|
|
53
|
+
.createObservableGauge(prefixedName(config, PROCESS_VIRTUAL_MEMORY), {
|
|
59
54
|
description: 'Virtual memory size in bytes.',
|
|
60
55
|
})
|
|
61
56
|
.addCallback((observable) => {
|
|
@@ -65,7 +60,7 @@ function osMemoryHeapLinuxMetric(meter, config) {
|
|
|
65
60
|
observable.observe(stats.VmSize, config?.labels);
|
|
66
61
|
});
|
|
67
62
|
meter
|
|
68
|
-
.createObservableGauge(
|
|
63
|
+
.createObservableGauge(prefixedName(config, PROCESS_HEAP), {
|
|
69
64
|
description: 'Process heap size in bytes.',
|
|
70
65
|
})
|
|
71
66
|
.addCallback((observable) => {
|