From 3cba596a968d8ff916d02d13b0b4d8f795f2bb7f Mon Sep 17 00:00:00 2001 From: pikalovArtemN Date: Fri, 17 May 2024 09:55:52 +0300 Subject: [PATCH] chore(instrumentation-runtime-node): sync with conventions --- .../src/consts/attributes.ts | 2 +- .../src/instrumentation.ts | 14 +- .../src/metrics/baseCollector.ts | 18 +- .../src/metrics/eventLoopDelayCollector.ts | 224 ++++++++++++++++++ .../src/metrics/eventLoopLagCollector.ts | 109 --------- .../metrics/eventLoopUtilizationCollector.ts | 2 +- .../src/metrics/gcCollector.ts | 21 +- .../src/metrics/heapSizeAndUsedCollector.ts | 6 +- .../metrics/heapSpacesSizeAndUsedCollector.ts | 140 ++++++++--- .../src/types/ConventionalNamePrefix.ts | 4 + 10 files changed, 370 insertions(+), 170 deletions(-) create mode 100644 plugins/node/instrumentation-runtime-node/src/metrics/eventLoopDelayCollector.ts delete mode 100644 plugins/node/instrumentation-runtime-node/src/metrics/eventLoopLagCollector.ts create mode 100644 plugins/node/instrumentation-runtime-node/src/types/ConventionalNamePrefix.ts diff --git a/plugins/node/instrumentation-runtime-node/src/consts/attributes.ts b/plugins/node/instrumentation-runtime-node/src/consts/attributes.ts index 73fdacf52b..f424e95ec5 100644 --- a/plugins/node/instrumentation-runtime-node/src/consts/attributes.ts +++ b/plugins/node/instrumentation-runtime-node/src/consts/attributes.ts @@ -1 +1 @@ -export const NODE_JS_VERSION_ATTRIBUTE = "nodejs.version" +export const NODE_JS_VERSION_ATTRIBUTE = "nodejsruntime.version" diff --git a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts index 1d5f59bca8..621b132cc1 100644 --- a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts +++ b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts @@ -19,16 +19,16 @@ import { VERSION } from './version'; import { RuntimeNodeInstrumentationConfig } from './types'; import { MetricCollector } from './types/metricCollector'; import { EventLoopUtilizationCollector } from './metrics/eventLoopUtilizationCollector'; -import { EventLoopLagCollector } from './metrics/eventLoopLagCollector'; +import { EventLoopDelayCollector } from './metrics/eventLoopDelayCollector'; import { GCCollector } from './metrics/gcCollector'; import { HeapSizeAndUsedCollector } from './metrics/heapSizeAndUsedCollector'; import { HeapSpacesSizeAndUsedCollector } from './metrics/heapSpacesSizeAndUsedCollector'; +import {ConventionalNamePrefix} from "./types/ConventionalNamePrefix"; const DEFAULT_CONFIG: RuntimeNodeInstrumentationConfig = { monitoringPrecision: 5000, }; -const namePrefix = 'jsruntime'; export class RuntimeNodeInstrumentation extends InstrumentationBase { private _collectors: MetricCollector[] = []; @@ -40,11 +40,11 @@ export class RuntimeNodeInstrumentation extends InstrumentationBase { Object.assign({}, DEFAULT_CONFIG, config) ); this._collectors = [ - new EventLoopUtilizationCollector(this._config, namePrefix), - new EventLoopLagCollector(this._config, namePrefix), - new GCCollector(this._config, namePrefix), - new HeapSizeAndUsedCollector(this._config, namePrefix), - new HeapSpacesSizeAndUsedCollector(this._config, namePrefix), + new EventLoopUtilizationCollector(this._config, ConventionalNamePrefix.NodeJsRuntime), + new EventLoopDelayCollector(this._config, ConventionalNamePrefix.NodeJsRuntime), + new GCCollector(this._config, ConventionalNamePrefix.V8EnjineRuntime), + new HeapSizeAndUsedCollector(this._config, ConventionalNamePrefix.V8EnjineRuntime), + new HeapSpacesSizeAndUsedCollector(this._config, ConventionalNamePrefix.V8EnjineRuntime), ]; if (this._config.enabled) { for (const collector of this._collectors) { diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/baseCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/baseCollector.ts index 438d4e9171..917c89435b 100644 --- a/plugins/node/instrumentation-runtime-node/src/metrics/baseCollector.ts +++ b/plugins/node/instrumentation-runtime-node/src/metrics/baseCollector.ts @@ -13,10 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { MetricCollector } from '../types/metricCollector'; -import { Meter } from '@opentelemetry/api'; -import { clearInterval } from 'node:timers'; -import { RuntimeNodeInstrumentationConfig } from '../types'; +import {MetricCollector} from '../types/metricCollector'; +import {Meter} from '@opentelemetry/api'; +import {clearInterval} from 'node:timers'; +import {RuntimeNodeInstrumentationConfig} from '../types'; +import {NODE_JS_VERSION_ATTRIBUTE} from "../consts/attributes"; + +type VersionAttribute = { [NODE_JS_VERSION_ATTRIBUTE]: string } export abstract class BaseCollector implements MetricCollector { protected _config: RuntimeNodeInstrumentationConfig = {}; @@ -24,13 +27,15 @@ export abstract class BaseCollector implements MetricCollector { protected namePrefix: string; private _interval: NodeJS.Timeout | undefined; protected _scrapeQueue: T[] = []; + protected versionAttribute: VersionAttribute - constructor( + protected constructor( config: RuntimeNodeInstrumentationConfig = {}, namePrefix: string ) { this._config = config; this.namePrefix = namePrefix; + this.versionAttribute = {[NODE_JS_VERSION_ATTRIBUTE]: process.version} } public disable(): void { @@ -67,7 +72,10 @@ export abstract class BaseCollector implements MetricCollector { } public abstract updateMetricInstruments(meter: Meter): void; + protected abstract internalEnable(): void; + protected abstract internalDisable(): void; + protected abstract scrape(): T; } diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopDelayCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopDelayCollector.ts new file mode 100644 index 0000000000..b970806f89 --- /dev/null +++ b/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopDelayCollector.ts @@ -0,0 +1,224 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {RuntimeNodeInstrumentationConfig} from '../types'; +import {Meter} from '@opentelemetry/api'; +import {IntervalHistogram} from 'node:perf_hooks'; +import {BaseCollector} from './baseCollector'; +import * as perf_hooks from 'node:perf_hooks'; + +enum NodeJsEventLoopDelay { + delay = 'eventloop.delay', + min = 'eventloop.delay.min', + max = 'eventloop.delay.max', + mean = 'eventloop.delay.mean', + stddev = 'eventloop.delay.stddev', + p50 = 'eventloop.delay.p50', + p90 = 'eventloop.delay.p90', + p99 = 'eventloop.delay.p99' +} + +export const metricNames: Record = { + [NodeJsEventLoopDelay.delay]: + { + description: + 'Lag of event loop in seconds.' + }, + [NodeJsEventLoopDelay.min]: + { + description: + 'The minimum recorded event loop delay.', + }, + [NodeJsEventLoopDelay.max]: + { + description: + 'The maximum recorded event loop delay.', + } + , + [NodeJsEventLoopDelay.mean]: + { + description: + 'The mean of the recorded event loop delays.', + } + , + [NodeJsEventLoopDelay.stddev]: + { + description: + 'The standard deviation of the recorded event loop delays.', + } + , + [NodeJsEventLoopDelay.p50]: + { + description: + 'The 50th percentile of the recorded event loop delays.', + } + , + [NodeJsEventLoopDelay.p90]: + { + description: + 'The 90th percentile of the recorded event loop delays.', + } + , + [NodeJsEventLoopDelay.p99]: + { + + description: + 'The 99th percentile of the recorded event loop delays.', + } + , +}; + +export interface EventLoopLagInformation { + min: number; + max: number; + mean: number; + stddev: number; + p50: number; + p90: number; + p99: number; +} + +export class EventLoopDelayCollector extends BaseCollector { + private _histogram: IntervalHistogram; + + + constructor( + config: RuntimeNodeInstrumentationConfig = {}, + namePrefix: string + ) { + super(config, namePrefix); + this._histogram = perf_hooks.monitorEventLoopDelay({ + resolution: config.monitoringPrecision, + }); + } + + updateMetricInstruments(meter: Meter): void { + const delay = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.delay}`, + { + description: metricNames[NodeJsEventLoopDelay.delay].description, + unit: 's', + } + ); + const delayMin = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.min}`, + { + description: metricNames[NodeJsEventLoopDelay.min].description, + unit: 's', + } + ); + const delayMax = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.max}`, + { + description: metricNames[NodeJsEventLoopDelay.max].description, + unit: 's', + } + ); + const delayMean = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.mean}`, + { + description: metricNames[NodeJsEventLoopDelay.mean].description, + unit: 's', + } + ); + const delayStddev = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.stddev}`, + { + description: metricNames[NodeJsEventLoopDelay.stddev].description, + unit: 's', + } + ); + const delayp50 = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.p50}`, + { + description: metricNames[NodeJsEventLoopDelay.p50].description, + unit: 's', + } + ); + const delayp90 = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.p90}`, + { + description: metricNames[NodeJsEventLoopDelay.p90].description, + unit: 's', + } + ); + const delayp99 = meter.createObservableGauge( + `${this.namePrefix}.${NodeJsEventLoopDelay.p99}`, + { + description: metricNames[NodeJsEventLoopDelay.p99].description, + unit: 's', + } + ); + + meter.addBatchObservableCallback( + async observableResult => { + if (this._scrapeQueue.length === 0) return; + + const data = this._scrapeQueue.shift(); + if (data === undefined) return; + + const start = process.hrtime(); + const delayResult = await new Promise(res => { + setImmediate((start: [number, number]) => { + res(this._reportEventloopLag(start)); + }, start); + }); + + observableResult.observe(delay, delayResult, this.versionAttribute); + observableResult.observe(delayMin, data.min, this.versionAttribute); + observableResult.observe(delayMax, data.max, this.versionAttribute); + observableResult.observe(delayMean, data.mean, this.versionAttribute); + observableResult.observe(delayStddev, data.stddev, this.versionAttribute); + observableResult.observe(delayp50, data.p50, this.versionAttribute); + observableResult.observe(delayp90, data.p90, this.versionAttribute); + observableResult.observe(delayp99, data.p99, this.versionAttribute); + + this._histogram.reset(); + }, + [delay, delayMin, delayMax, delayMean, delayStddev, delayp50, delayp90, delayp99] + ); + } + + internalEnable(): void { + this._histogram.enable(); + } + + internalDisable(): void { + this._histogram.disable(); + } + + protected scrape(): EventLoopLagInformation { + return { + min: this.checkNan(this._histogram.min / 1e9), + max: this.checkNan(this._histogram.max / 1e9), + mean: this.checkNan(this._histogram.mean / 1e9), + stddev: this.checkNan(this._histogram.stddev / 1e9), + p50: this.checkNan(this._histogram.percentile(90) / 1e9), + p90: this.checkNan(this._histogram.percentile(90) / 1e9), + p99: this.checkNan(this._histogram.percentile(99) / 1e9), + }; + } + + private _reportEventloopLag(start: [number, number]): number { + const delta = process.hrtime(start); + const nanosec = delta[0] * 1e9 + delta[1]; + const seconds = nanosec / 1e9; + return seconds; + } + + private checkNan(value: number) { + return isNaN(value) ? 0 : value; + } +} diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopLagCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopLagCollector.ts deleted file mode 100644 index 8abb273894..0000000000 --- a/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopLagCollector.ts +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {RuntimeNodeInstrumentationConfig} from '../types'; -import {Meter} from '@opentelemetry/api'; -import * as perf_hooks from 'node:perf_hooks'; -import {IntervalHistogram} from 'node:perf_hooks'; -import {BaseCollector} from './baseCollector'; - -const NODEJS_EVENTLOOP_LAG = 'eventloop.lag'; -export const NODEJS_EVENTLOOP_LAG_ATTRIBUTE_TYPE = 'eventloop.lag.type'; - - -export interface EventLoopLagInformation { - min: number; - max: number; - mean: number; - stddev: number; - p50: number; - p90: number; - p99: number; -} - -export class EventLoopLagCollector extends BaseCollector { - private _histogram: IntervalHistogram; - - constructor( - config: RuntimeNodeInstrumentationConfig = {}, - namePrefix: string - ) { - super(config, namePrefix); - this._histogram = perf_hooks.monitorEventLoopDelay({ - resolution: config.monitoringPrecision, - }); - } - - updateMetricInstruments(meter: Meter): void { - meter.createObservableGauge( - `${this.namePrefix}.${NODEJS_EVENTLOOP_LAG}`, - { - description: "Event loop lag.", - unit: 's' - }, - ).addCallback(async observableResult => { - if (this._scrapeQueue.length === 0) return; - - const data = this._scrapeQueue.shift(); - if (data === undefined) return; - - const start = process.hrtime(); - const lagResult = await new Promise(res => { - setImmediate((start: [number, number]) => { - res(this._reportEventloopLag(start)); - }, start); - }); - - observableResult.observe(lagResult); - - for (const [value, attributeType] of Object.keys(data).entries()) { - observableResult.observe(value, { - [`${this.namePrefix}.${NODEJS_EVENTLOOP_LAG_ATTRIBUTE_TYPE}`]: attributeType - }); - } - - }); - } - - internalEnable(): void { - this._histogram.enable(); - } - - internalDisable(): void { - this._histogram.disable(); - } - - protected scrape(): EventLoopLagInformation { - return { - min: this.checkNan(this._histogram.min / 1e9), - max: this.checkNan(this._histogram.max / 1e9), - mean: this.checkNan(this._histogram.mean / 1e9), - stddev: this.checkNan(this._histogram.stddev / 1e9), - p50: this.checkNan(this._histogram.percentile(90) / 1e9), - p90: this.checkNan(this._histogram.percentile(90) / 1e9), - p99: this.checkNan(this._histogram.percentile(99) / 1e9), - }; - } - - private _reportEventloopLag(start: [number, number]): number { - const delta = process.hrtime(start); - const nanosec = delta[0] * 1e9 + delta[1]; - return nanosec / 1e9; - } - - private checkNan(value: number) { - return isNaN(value) ? 0 : value; - } -} diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopUtilizationCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopUtilizationCollector.ts index 17eeec1228..80e42aef97 100644 --- a/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopUtilizationCollector.ts +++ b/plugins/node/instrumentation-runtime-node/src/metrics/eventLoopUtilizationCollector.ts @@ -44,7 +44,7 @@ export class EventLoopUtilizationCollector extends BaseCollector { - private _gcDurationByKindHistogram!: Histogram; + private _gcDurationByKindHistogram?: Histogram; private _observer: PerformanceObserver; constructor( @@ -45,10 +45,9 @@ export class GCCollector extends BaseCollector { // See: https://nodejs.org/docs/latest-v16.x/api/deprecations.html#deprecations_dep0152_extension_performanceentry_properties // @ts-ignore const kind = entry.detail ? kinds[entry.detail.kind] : kinds[entry.kind]; - console.log(); - this._gcDurationByKindHistogram.record( + this._gcDurationByKindHistogram?.record( entry.duration / 1000, - Object.assign({ kind }) + Object.assign({ [`${this.namePrefix}.gc.type`]: kind }, this.versionAttribute) ); }); } @@ -69,7 +68,7 @@ export class GCCollector extends BaseCollector { } internalEnable(): void { - this._observer.observe({ entryTypes: ['gc'] }); + this._observer.observe({entryTypes: ['gc']}); } internalDisable(): void { diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/heapSizeAndUsedCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/heapSizeAndUsedCollector.ts index d00c13df32..d35cd66eb5 100644 --- a/plugins/node/instrumentation-runtime-node/src/metrics/heapSizeAndUsedCollector.ts +++ b/plugins/node/instrumentation-runtime-node/src/metrics/heapSizeAndUsedCollector.ts @@ -42,10 +42,12 @@ export class HeapSizeAndUsedCollector extends BaseCollector const data = this._scrapeQueue.shift(); if (data === undefined) return; observableResult.observe(data.heapTotal, { - [`${this.namePrefix}.${NODEJS_HEAP_SIZE_STATE}`]: HeapSizes.Total + [`${this.namePrefix}.${NODEJS_HEAP_SIZE_STATE}`]: HeapSizes.Total, + ...this.versionAttribute }); observableResult.observe(data.heapUsed, { - [`${this.namePrefix}.${NODEJS_HEAP_SIZE_STATE}`]: HeapSizes.Used + [`${this.namePrefix}.${NODEJS_HEAP_SIZE_STATE}`]: HeapSizes.Used, + ...this.versionAttribute }); }); } diff --git a/plugins/node/instrumentation-runtime-node/src/metrics/heapSpacesSizeAndUsedCollector.ts b/plugins/node/instrumentation-runtime-node/src/metrics/heapSpacesSizeAndUsedCollector.ts index 20877e04ab..711f5c1559 100644 --- a/plugins/node/instrumentation-runtime-node/src/metrics/heapSpacesSizeAndUsedCollector.ts +++ b/plugins/node/instrumentation-runtime-node/src/metrics/heapSpacesSizeAndUsedCollector.ts @@ -20,10 +20,37 @@ import * as v8 from 'node:v8'; import {HeapSpaceInfo} from 'v8'; import {HeapSpaces} from "../types/heapSpaces"; -const NODEJS_HEAP_SPACE = 'heap.space'; -const NODEJS_HEAP_SPACE_STATE = 'heap.space.state'; -const NODEJS_HEAP_SPACE_SPACENAME = 'heap.space.spacename'; +enum V8HeapSpaceMetrics { + size = 'heap.size', + spaceSize = 'heap.space_size', + used = 'heap.space_used_size', + available = 'heap.space_available_size', + physical = 'heap.physical_space_size', +} + +export const metricNames: Record = { + [V8HeapSpaceMetrics.spaceSize]: { + description: + 'Process heap space size total from Node.js in bytes.', + }, + [V8HeapSpaceMetrics.size]: { + description: + 'Process heap space size total from Node.js in bytes.', + }, + [V8HeapSpaceMetrics.used]: { + description: + 'Process heap space size used from Node.js in bytes.', + }, + [V8HeapSpaceMetrics.available]: { + description: + 'Process heap space size available from Node.js in bytes.', + }, + [V8HeapSpaceMetrics.physical]: { + description: + 'Process heap space size available from Node.js in bytes.', + }, +} export class HeapSpacesSizeAndUsedCollector extends BaseCollector< HeapSpaceInfo[] @@ -36,41 +63,86 @@ export class HeapSpacesSizeAndUsedCollector extends BaseCollector< } updateMetricInstruments(meter: Meter): void { - meter.createObservableGauge( - `${this.namePrefix}.${NODEJS_HEAP_SPACE}`, + const heapSpaceSize = meter.createObservableGauge( + `${this.namePrefix}.${V8HeapSpaceMetrics.spaceSize}`, + { + description: metricNames[V8HeapSpaceMetrics.spaceSize].description, + unit: 'bytes', + } + ); + const heapSize = meter.createObservableGauge( + `${this.namePrefix}.${V8HeapSpaceMetrics.size}`, { - description: "Process heap space size total from Node.js in bytes.", - unit: 'By', + description: metricNames[V8HeapSpaceMetrics.size].description, + unit: 'bytes', } - ).addCallback(async observableResult => { - if (this._scrapeQueue.length === 0) return; - - const data = this._scrapeQueue.shift(); - if (data === undefined) return; - for (const space of data) { - const spaceName = space.space_name.substring( - 0, - space.space_name.indexOf('_space') - ); - observableResult.observe(space.space_size, { - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_SPACENAME}`]: spaceName, - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_STATE}`]: HeapSpaces.Total - }); - observableResult.observe(space.space_used_size, { - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_SPACENAME}`]: spaceName, - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_STATE}`]: HeapSpaces.Used - - }); - observableResult.observe( - space.space_available_size, - { - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_SPACENAME}`]: spaceName, - [`${this.namePrefix}.${NODEJS_HEAP_SPACE_STATE}`]: HeapSpaces.Availabe - } - ); + ); + const heapSpaceUsed = meter.createObservableGauge( + `${this.namePrefix}.${V8HeapSpaceMetrics.used}`, + { + description: metricNames[V8HeapSpaceMetrics.used].description, + unit: 'bytes', + } + ); + const heapSpaceAvailable = meter.createObservableGauge( + `${this.namePrefix}.${V8HeapSpaceMetrics.available}`, + { + description: metricNames[V8HeapSpaceMetrics.available].description, + unit: 'bytes', + } + ); + const heapSpacePhysical = meter.createObservableGauge( + `${this.namePrefix}.${V8HeapSpaceMetrics.physical}`, + { + description: metricNames[V8HeapSpaceMetrics.physical].description, + unit: 'bytes', } - }); + ); + const heapSpaceNameAttributeName = `${this.namePrefix}.heap.space.name` + const heapSizeStateAttributeName = `${this.namePrefix}.heap.size.state` + + + meter.addBatchObservableCallback( + observableResult => { + if (this._scrapeQueue.length === 0) return; + + const data = this._scrapeQueue.shift(); + if (data === undefined) return; + for (const space of data) { + + const spaceName = space.space_name + + observableResult.observe(heapSize, space.space_size, { + [heapSizeStateAttributeName]: HeapSpaces.Total, + }); + + observableResult.observe(heapSize, space.space_used_size, { + [heapSizeStateAttributeName]: HeapSpaces.Used, + }); + + observableResult.observe(heapSpaceSize, space.space_size, { + [heapSpaceNameAttributeName]: spaceName, + }); + + observableResult.observe(heapSpaceUsed, space.space_used_size, { + [heapSpaceNameAttributeName]: spaceName, + }); + + observableResult.observe( + heapSpaceAvailable, + space.space_available_size, + { + [heapSpaceNameAttributeName]: spaceName, + } + ); + observableResult.observe(heapSpacePhysical, space.physical_space_size, { + [heapSpaceNameAttributeName]: spaceName, + }); + } + }, + [heapSize, heapSpaceSize, heapSpaceUsed, heapSpaceAvailable, heapSpacePhysical] + ); } internalEnable(): void { diff --git a/plugins/node/instrumentation-runtime-node/src/types/ConventionalNamePrefix.ts b/plugins/node/instrumentation-runtime-node/src/types/ConventionalNamePrefix.ts new file mode 100644 index 0000000000..e11eea72e8 --- /dev/null +++ b/plugins/node/instrumentation-runtime-node/src/types/ConventionalNamePrefix.ts @@ -0,0 +1,4 @@ +export enum ConventionalNamePrefix { + NodeJsRuntime = "nodejsruntime", + V8EnjineRuntime = "v8jsengineruntime", +}