Skip to content

Commit 7cbc531

Browse files
committed
chore(opentelemetry-instrumentation): improve _warnOnPreloadedModules function not to show warning logs when the module is not marked as loaded
1 parent a05e581 commit 7cbc531

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1717
* feat(sdk-trace-base): implement on ending in span processor [#6024](https://github.com/open-telemetry/opentelemetry-js/pull/6024) @majanjua-amzn
1818
* note: this feature is experimental and subject to change
1919

20+
* chore(opentelemetry-instrumentation): improve `_warnOnPreloadedModules` function not to show warning logs when the module is not marked as loaded [#6095](https://github.com/open-telemetry/opentelemetry-js/pull/6095) @rlj1202
21+
2022
### :bug: Bug Fixes
2123

2224
### :books: Documentation

experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export abstract class InstrumentationBase<
148148
const { name } = module;
149149
try {
150150
const resolvedModule = require.resolve(name);
151-
if (require.cache[resolvedModule]) {
151+
if (require.cache[resolvedModule]?.loaded) {
152152
// Module is already cached, which means the instrumentation hook might not work
153153
this._diag.warn(
154154
`Module ${name} has been loaded before ${this.instrumentationName} so it might not work, please initialize it before requiring ${name}`

0 commit comments

Comments
 (0)