-
Notifications
You must be signed in to change notification settings - Fork 792
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
chore: more advanced plugin configuration #628
Conversation
Codecov Report
@@ Coverage Diff @@
## master #628 +/- ##
==========================================
+ Coverage 89.6% 91.35% +1.74%
==========================================
Files 191 215 +24
Lines 10034 9932 -102
Branches 925 913 -12
==========================================
+ Hits 8991 9073 +82
+ Misses 1043 859 -184
|
This is a great start. What are the valid use-cases of |
Right now the plugin options are the same regardless of if they're shared or if they're set on a single plugin, and only a couple exist. I was going to go through all plugins today and look at which configurations they use and create a set of options interfaces in |
@mayurkale22 one use case of shared configurations might be to set enhanced db reporting true for all db modules (mysql, pg, pg-pool, redis). new NodeTracer({
sharedPluginOptions: {
enhancedDatabaseReporting: true,
}
}); You may also want to set it true in general, but then disable for a single module which is also possible. new NodeTracer({
plugins: {
redis: {
options: {
enhancedDatabaseReporting: false,
},
},
},
sharedPluginOptions: {
enhancedDatabaseReporting: true,
},
}); |
I see, let's discuss this in tomorrow's SIG meeting. |
should we have some rules about naming params to avoid some problems with namespacing later? For example or maybe if param can be shared among all plugins it should start always with some prefix for example Another thing is that the shared params should be immutable so the plugins won't be able to overwrite it (Object.freeze) |
@obecny good point. maybe we're overcomplicating it. instead maybe we should just have a single configuration object shared to all plugins? new NodeTracer({
options: {
http: {
ignoreUrls: ["localhost"],
},
db: {
enhancedDatabaseReporting: true,
}
},
}); Then the whole |
This looks cleaner for me and I think you won't be able to pollute the the config with param that can break some other plugins. |
Unfortunately, ignoring some urls doesn't mean you want to ignore dns lookup as well... This looks cleaner for me too and passing the whole config can have some benefits (http/https/http2). |
Fully agree. It simplifies the implementation too. I'll update the PR today. |
@obecny @OlivierAlbertini take a look. It is drastically simpler now. The shared new NodeTracer({
options: {
http: {
ignoreIncomingPaths: ["/healthcheck"],
},
database: {
enhancedDatabaseReporting: true,
},
dns: {
ignoreHostnames: ["localhost"]
}
},
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left few comments, my biggest concern is mixing the configs between web and node which I think is bad idea and we should have clear separation for that, we can discuss this on sig meeting
|
||
// how long to wait for observer to collect information about resources | ||
// this is needed as event "load" is called before observer | ||
// hard to say how long it should really wait, seems like 300ms is | ||
// safe enough | ||
const OBSERVER_WAIT_TIME_MS = 300; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All plugin configurations are being centralized. That is the point of this PR
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think mixing plugin options between web and node is very bad idea. Things like database
, dns
etc will never be shared on web, and xhr
will never be shared on node.
I think that such changes w discuss could discuss on sig meeting and how we want to handle that. I would rather have web and node separation like this is done for example in core/platform
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can talk about it in SIG but I thought this was already pretty much agreed. We've had a couple discussions about it already.
* | ||
* @param options config objects to merge | ||
*/ | ||
export function mergeOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing unit tests.
This function doesn't guarantee the "frozen state" when option is array or object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another pass at this
packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead of checking each time if this._options.http exists (and for other plugin)
this._options.http &&
We could ensure that it is not null/undefined when we pass the options during the call at the enable
method ? WDYT ?
@@ -31,7 +31,10 @@ const tracer = new NodeTracer({ | |||
// You may use a package name or absolute path to the file. | |||
path: '@opentelemetry/plugin-http', | |||
// http plugin options | |||
options: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I understand correctly your comment #628 (comment),
This change should be updated, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, they just match now and are merged together. You can still configure one plugin to have different ignoreUrls
for example than the rest of the plugins.
if (this._config.applyCustomAttributesOnSpan) { | ||
if ( | ||
this._options.http && | ||
this._options.http.applyCustomAttributesOnSpan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._options.http?.applyCustomAttributesOnSpan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was having issues getting the compile to work with the new ts features for some reason. didn't feel like spending a lot of time to figure out what was wrong.
dns?: DNSPluginOptions; | ||
http?: HttpPluginOptions; | ||
xhr?: XMLHttpRequestPluginOptions; | ||
custom?: CustomPluginOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about:
[custom: string]: any;
People would be able to add their own plugin like this:
const options: PluginOptions = {
http: {
serverName: 'hello',
},
amqp: {
something: 'else'
}
}
I don't have a strong opinion on this, I'm just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a whole section named custom
which allows you to put custom config options there.
good idea |
Which problem is this PR solving?
Short description of the changes
NodeTracer
configs can now be configured in the following ways:Default configuration and plugins
Configure a plugin with options
In this scenario, the http plugin will receive the
httpPluginOption
configuration.Configure shared plugin options
In this scenario, the http plugin will receive the
httpPluginOption
configuration, the https plugin will receive thehttpsPluginOption
configuration, and both will receive thesharedPluginOption
configuration.Disable a plugin and leave all others enabled
You no longer need to explicitly give the whole configuration object