Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge user provided plugin configs with default supported configs #616

Closed
mayurkale22 opened this issue Dec 12, 2019 · 6 comments · Fixed by #980
Closed

Merge user provided plugin configs with default supported configs #616

mayurkale22 opened this issue Dec 12, 2019 · 6 comments · Fixed by #980
Assignees

Comments

@mayurkale22
Copy link
Member

Currently, we allow users to config the plugins as per their requirement (which is great), but newly provided config replaces the existing default config instead of merging with it.

For example: If i decided to disable certain plugin or change its config, I have to update that plugin and add all other plugins to activate them.

const tracer = new NodeTracer({
  plugins: { 
    dns: { enabled: false },
    http: { enabled: true, path: ... },
    mysql: { enabled: true, path: ... },
    ...
   }
});

Expected behavior: Update only specific plugin and others should work seamlessly.

const tracer = new NodeTracer({
  plugins: { 
    dns: { path: '<new path>' },
   }
});

Code reference at:

this._pluginLoader.load(config.plugins || DEFAULT_INSTRUMENTATION_PLUGINS);

@mayurkale22 mayurkale22 added feature-request up-for-grabs Good for taking. Extra help will be provided by maintainers labels Dec 12, 2019
@mayurkale22 mayurkale22 added this to the Alpha v0.4 milestone Dec 12, 2019
@dyladan
Copy link
Member

dyladan commented Dec 12, 2019

I think at the same time we should define a configuration interface for configuring behavior of plugins.

Right now this is our plugin configuration interface

export interface PluginConfig {
    /**
     * Whether to enable the plugin.
     * @default true
     */
    enabled?: boolean;
    /**
     * Path of the trace plugin to load.
     * @default '@opentelemetry/plugin-http' in case of http.
     */
    path?: string;
    /**
     * Request methods that match any string in ignoreMethods will not be traced.
     */
    ignoreMethods?: string[];
    /**
     * URLs that partially match any regex in ignoreUrls will not be traced.
     * In addition, URLs that are _exact matches_ of strings in ignoreUrls will
     * also not be traced.
     */
    ignoreUrls?: Array<string | RegExp>;
    /**
     * List of internal files that need patch and are not exported by
     * default.
     */
    internalFilesExports?: PluginInternalFiles;
    /**
     * If true, additional information about query parameters and
     * results will be attached (as `attributes`) to spans representing
     * database operations.
     */
    enhancedDatabaseReporting?: boolean;
}
  • ignoreMethods
    • unused
    • definition of "method" is not clear
  • ignoreUrls
    • used by xhr
    • other plugins that could benefit from this but don't
  • internalFilesExports
    • used by grpc, but not configured by user. this set by the plugin loader
    • should not be a user-visible configuration
  • enhancedDatabaseReporting
    • unused
    • not well defined behavior

I am proposing to separate user-configurable options and internal configuration similar to the following:

const tracer = new NodeTracer({
  plugins: { 
    dns: { options: { someconfig: true } },
   },
   sharedPluginOptions: {
      someotherconfig: true,
   }
});

Additionally, I think we should better define and document the configuration options we have that could be useful for other plugins.

@dyladan dyladan self-assigned this Dec 13, 2019
@dyladan dyladan removed the up-for-grabs Good for taking. Extra help will be provided by maintainers label Dec 13, 2019
@OlivierAlbertini
Copy link
Member

I like the idea of

sharedPluginOptions: {
      someotherconfig: true,
   }

@dyladan
Copy link
Member

dyladan commented Apr 16, 2020

We should look at how other sigs are configuring plugins. Ruby has some way to provide a hash of options directly in the gemfile (similar to package.json), and I know some js packages allow configuration inside the package.json. Maybe this is a good way for us to go.

@naseemkullah
Copy link
Member

For now can we dial back the scope and just merge user defined config with the default config? as far as having default values for enabled and path remain untouched so one could simply:

  plugins: {
    http: {
      ignoreIncomingPaths: [/\/healthz/],
    },
  },

rather than:

  plugins: {
    http: {
      enabled: true,
      ignoreIncomingPaths: [/\/healthz/],
      path: '@opentelemetry/plugin-http',
    },
    mysql: { enabled: true, path: '@opentelemetry/plugin-mysql' },
    redis: { enabled: true, path: '@opentelemetry/plugin-redis' },
  },

@dyladan
Copy link
Member

dyladan commented Apr 22, 2020

Yes I think this is a good idea. If you want to make a PR that would be great, or else I can do it when I have time.

@naseemkullah
Copy link
Member

Yes I think this is a good idea. If you want to make a PR that would be great, or else I can do it when I have time.

Sure thing! I'll submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants