-
Notifications
You must be signed in to change notification settings - Fork 223
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: refactor module patch handling in Instrumentation class #3658
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This refactors how module patch handlers are loaded and the Instrumentation class file. There is now a PatcherRegistry that is a little smarter than the `_patches` object before it. The main change is that we now use RITM's internals:true option so that our `onRequire` hook is called with module sub-paths. This will allow #3657 to hook both "mongodb" and "mongodb/lib/cmap/connection_pool.js", and avoid a RITM bug where "mongodb" & "mongodb/lib/cmap/connection_pool" (no extension, indicating a "sub-module") don't work together. Benefits and other changes: - With the smarter "PatcherRegistry" the module name can be used in `disableInstrumentations` to disable any patchers for that module. E.g. `disableInstrumentations=next` will disable all four `next`-related patchers. - A custom "lambda" name is now usable to disable the Lambda instr, FWIW. - (Note: we *could* also add custom disableInstrumentations keys for other modules, e.g. perhaps "aws-sdk" for all those.) - Some edge cases with the (rare, and undocumented) `config.addPatch` config var have been cleaned up. - Loading of the lambda-handler has been refactored a bit to no longer need to know internal details of the instrumentation module. Refs: #3657 Closes: #2992
github-actions
bot
added
the
agent-nodejs
Make available for APM Agents project planning.
label
Oct 6, 2023
trentm
commented
Oct 6, 2023
david-luna
previously approved these changes
Oct 9, 2023
Looks good. I'm leaving already the approval so you can merge when you finish the the caching of module versions |
…redis' for redis@4 instrumentation and add a test for that
david-luna
approved these changes
Oct 11, 2023
This was referenced Oct 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactors how module patch handlers are loaded and the Instrumentation class file. There is now a PatcherRegistry that is a little smarter than the
_patches
object before it.The main change is that we now use RITM's internals:true option so that our
onRequire
hook is called with module sub-paths. This will allow #3657 to hook both "mongodb" and "mongodb/lib/cmap/connection_pool.js", and avoid a RITM bug where "mongodb" &"mongodb/lib/cmap/connection_pool" (no extension, indicating a "sub-module") don't work together.
Benefits and other changes:
disableInstrumentations
to disable any patchers for that module. E.g.disableInstrumentations=next
will disable all fournext
-related patchers.config.addPatch
config var have been cleaned up.Refs: #3657
Closes: #2992