Skip to content

Commit

Permalink
fix(perf_hooks): don't export when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
d4nyll committed Jan 16, 2024
1 parent 0ecc3e4 commit e8e81a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class PerfHooksInstrumentation extends InstrumentationBase {
}

override disable() {
this._clearELU();
clearInterval(this._interval);
this._interval = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,12 @@ describe('nodejs.performance.event_loop.utilization', () => {
);
assert.strictEqual(metrics[0].descriptor.unit, '1');
});

it('should stop exporting metrics when disabled', async () => {
instrumentation.disable();
await new Promise(resolve => setTimeout(resolve, EXPORT_INTERVAL));
const resourceMetrics = metricExporter.getMetrics();
const scopeMetrics = resourceMetrics[0].scopeMetrics;
assert.strictEqual(scopeMetrics.length, 0);
});
});

0 comments on commit e8e81a7

Please sign in to comment.