-
Notifications
You must be signed in to change notification settings - Fork 318
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
make tracer config available to plugins #3235
Conversation
Overall package sizeSelf size: 4.31 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
8d8339b
to
1d75d1a
Compare
Codecov Report
@@ Coverage Diff @@
## master #3235 +/- ##
===========================================
+ Coverage 68.16% 86.02% +17.85%
===========================================
Files 184 190 +6
Lines 6990 7451 +461
Branches 33 33
===========================================
+ Hits 4765 6410 +1645
+ Misses 2225 1041 -1184
... and 62 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
1d75d1a
to
67ae56f
Compare
@@ -38,13 +38,17 @@ class DatabasePlugin extends StoragePlugin { | |||
} | |||
|
|||
injectDbmQuery (query, serviceName, isPreparedStatement = false) { | |||
if (this.config.dbmPropagationMode === 'disabled') { | |||
const dbmPropagationMode = this.getConfig('dbmPropagationMode') |
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 is an example of how plugins should be loading overridable configuration 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.
This is adding overhead in possibly hot paths.
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've removed getConfig
67ae56f
to
0654b7a
Compare
0654b7a
to
c6797e4
Compare
this._subscriptions = [] | ||
this._enabled = false | ||
this._tracer = tracer | ||
this.config = {} // plugin-specific configuration, unset until .configure() is called |
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 value is set later but I like having its presence be a little more explicit.
// helper method to retrieve a configuration value that is expected to be overridden | ||
getConfig (name) { | ||
if (name in this.config) { | ||
return this.config[name] | ||
} | ||
|
||
if (name in this._tracerConfig) { | ||
return this._tracerConfig[name] | ||
} |
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 I would prefer config objects for each plugin be pre-computed so we don't have to call getConfig
and do all this checking at runtime every time. Could try nesting plugin configs under the global configs something like config.plugins.$plugin_name
and compute the full config object ahead of time. If you want to retain the fall-through logic it could also do something like Object.setPrototypeOf(pluginConfig, tracerConfig)
or probably replace tracerConfig
with something a little more specifically tuned to just the things we've explicitly marked as what we want to be available to plugins.
I'm not sure I like the idea of automatic fallback on everything as there's then a key conflict situation to worry about where we may want a global config available which shares a name with a plugin config or we may not want a particular config setting if not explicitly provided. 🤔
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 could indeed be conflicts, and not all configurations should be available to plugins either.
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.
The fall through logic seems like a bit of a hack and getConfig
was just moving that around a little bit. I've simplified the PR to not use fallback logic and instead expect plugins to know if the configuration is plugin-specific or tracer-global.
@@ -38,13 +38,17 @@ class DatabasePlugin extends StoragePlugin { | |||
} | |||
|
|||
injectDbmQuery (query, serviceName, isPreparedStatement = false) { | |||
if (this.config.dbmPropagationMode === 'disabled') { | |||
const dbmPropagationMode = this.getConfig('dbmPropagationMode') |
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 is adding overhead in possibly hot paths.
// helper method to retrieve a configuration value that is expected to be overridden | ||
getConfig (name) { | ||
if (name in this.config) { | ||
return this.config[name] | ||
} | ||
|
||
if (name in this._tracerConfig) { | ||
return this._tracerConfig[name] | ||
} |
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 could indeed be conflicts, and not all configurations should be available to plugins either.
@@ -26,10 +26,23 @@ class Subscription { | |||
} | |||
|
|||
module.exports = class Plugin { | |||
constructor (tracer) { | |||
constructor (tracer, tracerConfig) { |
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.
Passing this here means that if the tracer config is updated, the update won't propagate anymore.
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.
tracerConfig is an object, so wouldn't modifying properties of that object propagate everywhere?
c6797e4
to
ede03e1
Compare
ede03e1
to
e013f23
Compare
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 the differentiated config approach is reasonable, but I feel like we should probably do a more complete refactoring of the config system at some point. 🤔
I agree 100% |
What does this PR do?
_getSharedConfig
to pass from tracer config to plugin configMotivation
Plugin Checklist