You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, instrumentations are loaded by the PluginLoader which is called by the NodeTracerProvider.
This setup assumes that the user wants to use traces and not just metrics
This setup encourages tracing-only plugins
This setup does not allow easily sharing plugin instances between meter providers and tracer providers.
Suggested Solution
Remove the PluginLoader entirely
Update base plugin class to include a hook method which registers a require in the middle hook
import*ashookfrom"require-in-the-middle";abstractclassBasePlugin{abstractreadonlyname: string;abstractreadonlyversion?: string;abstractreadonlypatchModule: string;abstractreadonlysupportedVersions: string[];abstractenable(moduleExports: T,logger: Logger,config?: PluginConfig): T;constructor(config){}hook(){hook([this.modulename],(exports: unknown,name: string,basedir?: string)=>{if(basedir&&this._alreadyRequiredModule(basedir)){// log warningreturnexports;}constversion=_getVersion(basedir);if(!_isVersionSupported(version)){// log?returnexports;}// kept the old signature for backwards compatibility reasons.// this should allow us to keep the old method and upgrade over time.returnthis.enable(exports,this.logger,this.config);});}private_alreadyRequiredModule(baseDir: string): boolean{constcache=newSet(Object.keys(require.cache));}}classHttpPluginextendsBasePlugin{publicreadonlyname: "@opentelemetry/plugin-http";publicreadonlyversion: "0.8.1";publicreadonlypatchModule: "http";// same enable method as current}consthttpPlugin=newHttpPlugin({/* config */});httpPlugin.hook();
This would also allow us to export a hook method from the plugin metapackage, which the @opentelemetry/node-sdk could call, moving the list of default supported plugins out of the node class and making the metapackage act as the default plugins list.
Currently, instrumentations are loaded by the
PluginLoader
which is called by theNodeTracerProvider
.Suggested Solution
PluginLoader
entirelyhook
method which registers a require in the middle hookThis would also allow us to export a
hook
method from the plugin metapackage, which the@opentelemetry/node-sdk
could call, moving the list of default supported plugins out of the node class and making the metapackage act as the default plugins list.The text was updated successfully, but these errors were encountered: