Skip to content

Commit

Permalink
cr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nozik committed Apr 26, 2022
1 parent 4b36beb commit 4021e62
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,18 @@ export abstract class InstrumentationBase<T = any>
}

private _warnOnPreloadedModules(): void {
const preloadedModules: string[] = [];
this._modules.forEach((module: InstrumentationModuleDefinition<T>) => {
const { name } = module;
try {
const resolvedModule = require.resolve(name);
if (require.cache[resolvedModule]) {
// Module is already cached, which means the instrumentation hook might not work
preloadedModules.push(name);
this._diag.warn(`Module ${name} has been loaded before ${this.instrumentationName} so it might not work, please initialize it before requiring ${name}`);
}
} catch {
// Module isn't available, we can simply skip
}
});

if (!preloadedModules.length) {
return;
}

this._diag.warn(`Some modules (${preloadedModules.join(', ')}) were already required when their respective plugin was loaded, some plugins might not work. Make sure the SDK is setup before you require in other modules.`);
}

private _extractPackageVersion(baseDir: string): string | undefined {
Expand Down

0 comments on commit 4021e62

Please sign in to comment.