File tree 2 files changed +8
-1
lines changed
packages/opentelemetry-node
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,12 @@ In the following example:
82
82
- the default express plugin is disabled
83
83
- the http plugin has a custom config for a ` requestHook `
84
84
- the customPlugin is loaded from the user supplied path
85
+ - the customPlugin2 is resolved locally and injected
85
86
- all default plugins are still loaded if installed.
86
87
87
88
``` js
89
+ import {plugin as httpsPlugin } from ' @opentelemetry/plugin-https' ;
90
+
88
91
const provider = new NodeTracerProvider ({
89
92
plugins: {
90
93
express: {
@@ -98,6 +101,9 @@ const provider = new NodeTracerProvider({
98
101
customPlugin: {
99
102
path: " /path/to/custom/module" ,
100
103
},
104
+ customPlugin2: {
105
+ plugin: httpsPlugin,
106
+ },
101
107
},
102
108
});
103
109
```
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ export class PluginLoader {
131
131
if ( this . _hookState !== HookState . ENABLED ) return exports ;
132
132
const config = pluginsToLoad [ name ] ;
133
133
const modulePath = config . path ! ;
134
+ const modulePlugin = config . plugin ;
134
135
let version = null ;
135
136
136
137
if ( ! baseDir ) {
@@ -170,7 +171,7 @@ export class PluginLoader {
170
171
171
172
// Expecting a plugin from module;
172
173
try {
173
- const plugin : Plugin = require ( modulePath ) . plugin ;
174
+ const plugin : Plugin = modulePlugin ?? require ( modulePath ) . plugin ;
174
175
if ( ! utils . isSupportedVersion ( version , plugin . supportedVersions ) ) {
175
176
this . logger . warn (
176
177
`PluginLoader#load: Plugin ${ name } only supports module ${ plugin . moduleName } with the versions: ${ plugin . supportedVersions } `
You can’t perform that action at this time.
0 commit comments