diff --git a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts index 9630959296..c5e58f9c69 100644 --- a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts +++ b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts @@ -15,7 +15,6 @@ */ import { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { RuntimeNodeInstrumentationConfig } from './types'; import { MetricCollector } from './types/metricCollector'; import { EventLoopUtilizationCollector } from './metrics/eventLoopUtilizationCollector'; @@ -23,17 +22,15 @@ import { EventLoopDelayCollector } from './metrics/eventLoopDelayCollector'; import { GCCollector } from './metrics/gcCollector'; import { HeapSpacesSizeAndUsedCollector } from './metrics/heapSpacesSizeAndUsedCollector'; import { ConventionalNamePrefix } from './types/ConventionalNamePrefix'; -import {EventLoopTimeCollector} from "./metrics/eventLoopTimeCollector"; +import { EventLoopTimeCollector } from './metrics/eventLoopTimeCollector'; +import { PACKAGE_VERSION, PACKAGE_NAME } from './version'; const DEFAULT_CONFIG: RuntimeNodeInstrumentationConfig = { monitoringPrecision: 10, }; export class RuntimeNodeInstrumentation extends InstrumentationBase { - private _ELUs: EventLoopUtilization[] = []; - private _interval: NodeJS.Timeout | undefined; - private _collectors: MetricCollector[] = []; - + private readonly _collectors: MetricCollector[] = []; constructor(config: RuntimeNodeInstrumentationConfig = {}) { super( @@ -46,10 +43,7 @@ export class RuntimeNodeInstrumentation extends InstrumentationBase this._addELU(), - this.getConfig().eventLoopUtilizationMeasurementInterval - ); - - for (const collector of this._collectors) { collector.enable(); } diff --git a/plugins/node/instrumentation-runtime-node/test/event_loop_delay.test.ts b/plugins/node/instrumentation-runtime-node/test/event_loop_delay.test.ts index 4dec2a2939..9571ff23c6 100644 --- a/plugins/node/instrumentation-runtime-node/test/event_loop_delay.test.ts +++ b/plugins/node/instrumentation-runtime-node/test/event_loop_delay.test.ts @@ -21,7 +21,6 @@ import { TestMetricReader } from './testMetricsReader'; import { metricNames } from '../src/metrics/eventLoopDelayCollector'; import { ConventionalNamePrefix } from '../src/types/ConventionalNamePrefix'; - describe(`${ConventionalNamePrefix.NodeJs}.eventloop`, function () { let metricReader: TestMetricReader; let meterProvider: MeterProvider; @@ -41,9 +40,7 @@ describe(`${ConventionalNamePrefix.NodeJs}.eventloop`, function () { instrumentation.setMeterProvider(meterProvider); // act - await new Promise(resolve => - setTimeout(resolve, 100) - ); + await new Promise(resolve => setTimeout(resolve, 100)); const { resourceMetrics, errors } = await metricReader.collect(); // assert diff --git a/plugins/node/instrumentation-runtime-node/test/event_loop_time.test.ts b/plugins/node/instrumentation-runtime-node/test/event_loop_time.test.ts index d3a7ae39a3..ce18f432c6 100644 --- a/plugins/node/instrumentation-runtime-node/test/event_loop_time.test.ts +++ b/plugins/node/instrumentation-runtime-node/test/event_loop_time.test.ts @@ -19,7 +19,7 @@ import { RuntimeNodeInstrumentation } from '../src'; import * as assert from 'assert'; import { TestMetricReader } from './testMetricsReader'; import { ConventionalNamePrefix } from '../src/types/ConventionalNamePrefix'; -import { NODEJS_EVENT_LOOP_TIME } from "../src/metrics/eventLoopTimeCollector"; +import { NODEJS_EVENT_LOOP_TIME } from '../src/metrics/eventLoopTimeCollector'; const MEASUREMENT_INTERVAL = 10; @@ -77,7 +77,6 @@ describe(`${ConventionalNamePrefix.NodeJs}.${NODEJS_EVENT_LOOP_TIME}`, function assert.notEqual(timeMetric, undefined, 'metric not found'); - assert.strictEqual( timeMetric!.descriptor.name, `${ConventionalNamePrefix.NodeJs}.${NODEJS_EVENT_LOOP_TIME}`, diff --git a/plugins/node/instrumentation-runtime-node/test/event_loop_utilization.test.ts b/plugins/node/instrumentation-runtime-node/test/event_loop_utilization.test.ts index ea0734f541..cb9c7a04c2 100644 --- a/plugins/node/instrumentation-runtime-node/test/event_loop_utilization.test.ts +++ b/plugins/node/instrumentation-runtime-node/test/event_loop_utilization.test.ts @@ -77,7 +77,6 @@ describe(`${ConventionalNamePrefix.NodeJs}.${NODEJS_EVENT_LOOP_UTILIZATION}`, fu assert.notEqual(utilizationMetric, undefined, 'metric not found'); - assert.strictEqual( utilizationMetric!.descriptor.name, `${ConventionalNamePrefix.NodeJs}.${NODEJS_EVENT_LOOP_UTILIZATION}`,