Skip to content

Commit 215c2b5

Browse files
authored
fix(instrumentation-runtime-node): fix .isEnabled() (#2946)
This instrumentation overrides the enable() and disable() methods. However, it was not calling super for those, so the private '_enabled' state on the super class was not getting updated, which broke 'instr.isEnable()'. It would always return false.
1 parent e9987a7 commit 215c2b5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/instrumentation-runtime-node/src/instrumentation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class RuntimeNodeInstrumentation extends InstrumentationBase<RuntimeNodeI
7373
}
7474

7575
override enable() {
76+
super.enable();
7677
if (!this._collectors) return;
7778

7879
for (const collector of this._collectors) {
@@ -81,6 +82,7 @@ export class RuntimeNodeInstrumentation extends InstrumentationBase<RuntimeNodeI
8182
}
8283

8384
override disable() {
85+
super.disable();
8486
for (const collector of this._collectors) {
8587
collector.disable();
8688
}

packages/instrumentation-runtime-node/test/instrumentation.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ describe('instrumentation', function () {
6767
const scopeMetrics = firstCollections.resourceMetrics.scopeMetrics;
6868
assert.strictEqual(scopeMetrics.length, 0);
6969

70+
assert.equal(instrumentation.isEnabled(), false);
7071
instrumentation.enable();
72+
assert.equal(instrumentation.isEnabled(), true);
7173
await new Promise(resolve => setTimeout(resolve, MEASUREMENT_INTERVAL * 5));
7274

7375
const secondCollection = await metricReader.collect();

0 commit comments

Comments
 (0)