Skip to content

Commit b755cfa

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

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
@@ -14,6 +14,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1414

1515
### :rocket: Features
1616

17+
* chore(opentelemetry-instrumentation): improve `_warnOnPreloadedModules` function not to show warning logs when the module is not marked as loaded
18+
1719
### :bug: Bug Fixes
1820

1921
### :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)