Skip to content

Commit

Permalink
fix: use deepmerge to merge user configured and default plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Naseem <[email protected]>
  • Loading branch information
Naseem committed Apr 23, 2020
1 parent fd1f565 commit 8402db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/opentelemetry-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"devDependencies": {
"@opentelemetry/context-base": "^0.6.1",
"@opentelemetry/plugin-http": "^0.6.1",
"@opentelemetry/resources": "^0.6.1",
"@types/mocha": "^7.0.0",
"@types/node": "^12.6.8",
Expand All @@ -64,6 +65,7 @@
"@opentelemetry/context-async-hooks": "^0.6.1",
"@opentelemetry/core": "^0.6.1",
"@opentelemetry/tracing": "^0.6.1",
"deepmerge": "^4.2.2",
"require-in-the-middle": "^5.0.0",
"semver": "^7.1.3"
}
Expand Down
7 changes: 6 additions & 1 deletion packages/opentelemetry-node/src/NodeTracerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@opentelemetry/tracing';
import { DEFAULT_INSTRUMENTATION_PLUGINS, NodeTracerConfig } from './config';
import { PluginLoader } from './instrumentation/PluginLoader';
import * as merge from 'deepmerge';

/**
* Register this TracerProvider for use with the OpenTelemetry API.
Expand All @@ -40,7 +41,11 @@ export class NodeTracerProvider extends BasicTracerProvider {

this._pluginLoader = new PluginLoader(this, this.logger);
// Merge default plugins with user supplied config
this._pluginLoader.load({...DEFAULT_INSTRUMENTATION_PLUGINS, ...config.plugins});
this._pluginLoader.load(
config.plugins
? merge(DEFAULT_INSTRUMENTATION_PLUGINS, config.plugins)
: DEFAULT_INSTRUMENTATION_PLUGINS
);
}

stop() {
Expand Down

0 comments on commit 8402db4

Please sign in to comment.