-
Notifications
You must be signed in to change notification settings - Fork 598
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
auto convert :auto to :prepend/:chain in config #1930
Conversation
For `:'instrumentation.*'` configuration parameters that are set to :auto (the default), the agent will automatically determine whether to use method prepending or chaining. The agent will now update its in-memory configuration to give each relevant parameter a value of either :prepend or :chain so that the result of the determination can be introspected. This is intended to help 3rd party libraries that wish to further enhance the agent's instrumentation capabilities by prepending or chaining additional logic. Environment variable, YAML file, and server-side configuration based values are not impacted.
@fallwith There is a bug in the replace_or_add_config method which updates the config when there is any new config is received from server source or any other source. |
add missing ** closing style Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
when resetting the configuration manager's cache, do not allow already determined dependency detection params to be reverted back to either `nil` or `'auto'`.
Hi @prateek-ap. The dependency detection based parameters can't be configured server-side so we should be okay to simply preserve them after auto-detection. I have updated the cache resetting logic with 7735f92. |
for each default source test, make sure the config cache is reset
Hi @fallwith The cache data is now preserving, Thanks. |
(for the sake of older Rubies) don't attempt to reference `@cache`, even for an evaluation of truthiness, without making sure it is defined first
@prateek-ap this is a great point! The Mongo and Excon instrumentation config parameters are definitely odd. As you point out, they are not set to The good news is that you don't not have to worry about the |
Hi @fallwith I understand that APM doesn't doing alias or prepend on mongo and excon library and that's why, by default have enabled, but In case of Security agent I will need a deterministic decision, otherwise, I will instrument using default approach (i.e. prepend) and that can conflict with other library instrumenting mongo or excon may be using chaining. |
if config_key && auto_configured? | ||
NewRelic::Agent.config.instance_variable_get(:@cache)[config_key] = use_prepend ? :prepend : :chain | ||
end | ||
use_prepend |
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.
Is this saying we are always returning true
or false
?
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.
Precisely. We hook into this existing method that returns a boolean, so here we make sure we still always return a boolean.
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.
Got it I see what is happening now. Thank you :)
'becames' -> 'becomes' comment spelling fix
SimpleCov Report
|
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 great as-is, take or leave the CHANGELOG rec.
CHANGELOG.md
Outdated
@@ -2,6 +2,10 @@ | |||
|
|||
## dev | |||
|
|||
- **Feature: The agent configuration will now reflect whether method prepending or chaining was used per instrumentation** |
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.
Would you be up for changing "method prepending or chaining" to "module prepending or method chaining" in the title and the body copy?
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.
Certainly! Addressed with bf3b5ee
Hi @prateek-ap. With this PR/branch, for all config parameters that start with
So if you see For Mongo and Excon in particular, you are welcome to follow the same pattern that we use for working with those libraries (for Mongo we subscribe, and for Excon we add to the middleware array) or if you prefer you can use prepend. Either way, you should not conflict with the agent for those two. |
Update PR 1930's CHANGELOG entry to use the correct "module prepending" and "method chaining" verbiage. Also replace the potentially confusing "per" with "for".
bf3b5ee
@prateek-ap these changes are in the |
With [1930](#1930) the agent will now automatically convert any configured instrumentation value of `:auto` into either `:prepend` or `:chain` once the determination of which approach to take has been dynamically determined. This will allow the agent's config to be inspected after the `:prepend` / `:chain` determination is made to see what `:auto` actually becomes under the hood. But 1930 left an edge case gap open in the form of not allowing the configuration to convey instrumentation with unsatisfied dependencies. If a config value is set to `:prepend` or `:chain` in the configuration (overriding the default `:auto` value) and a dependency is unsatisfied (the library to instrument is not found on the system, it is of an unsupported version, etc.) then the value would end up staying as `:prepend` or `:chain` and incorrectly convey to anyone inspecting the config that a certain method of instrumentation was used when in actuality no instrumentation was performed at all. Now, if an instrumentation's dependencies are unsatisfied, the corresponding configuration value will be updated with a value of `:unsatisfied`.
For
:'instrumentation.*'
configuration parameters that are set to :auto (the default), the agent will automatically determine whether to use method prepending or chaining. The agent will now update its in-memory configuration to give each relevant parameter a value of either :prepend or :chain so that the result of the determination can be introspected. This is intended to help 3rd party libraries that wish to further enhance the agent's instrumentation capabilities by prepending or chaining additional logic. Environment variable, YAML file, and server-side configuration based values are not impacted.resolves #1924