-
Notifications
You must be signed in to change notification settings - Fork 143
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
Recursively patch any given module functions with capture #113
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
73602ab
Add recursive function and method patching with capture
hasier 093f057
Patch with only import hooks
hasier 3ed4540
Remove setup patching, add envvar to patch modules on Django app ready
hasier d16e9bb
Prevent double patching and add startup patching segment
hasier f42546d
Add module pattern ignore
hasier cf7e233
Add function attribute and check to detect whether already decorated
hasier 6609c00
Add tests
hasier d6655e7
Fix PY3 patching + importing and amend tests
hasier 279926f
Add ignore tests
hasier 5d5b3ae
Fix class methods, classmethods and staticmethods, and add tests
hasier 311b46d
Update docs
hasier 6459ca0
Fix referenced inherited methods
hasier f3f6f83
Avoid automatically patching classmethods
hasier 3f016ce
Add settings variable to opt-in for import-time parent segment
hasier 5694ce8
Merge branch 'master' into recursive-module-patch-2
hasier 39f2ef8
Patch pg8000 tests only once per module
hasier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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 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 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 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 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 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 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
Oops, something went wrong.
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.
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.
Sorry for the late response. Other parts look good. Why capture the patching as a segment during startup? This generates dangling traces and doesn't seem to be useful.
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 worries, thanks for your comment. I found it useful for our project, as we were patching in the
settings
file and the result was similar. It is also less of a hassle to add imports.Still, I agree it does not look especially good. I gave it a thought back then and didn't come with any other solution... Any ideas? Where do you usually find useful to apply the patching in a Django app?
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 this is the right place to configure what modules to patch. I'm asking regarding the
with xray_recorder.in_segment('startup'):
. Do you mean you have real subsegments generated during patching so you need to create astartup
segment?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.
Oh I see. Yes, now I remember I added that because during startup I was seeing subsegments that failed to have a parent. I guess I did so because some functions decorated with
.capture()
are being called during startup/patching, mainly due to importing different modules (it's a really big project). I don't think it would be a big issue if we would not have a parent for those subsegments, but back then I guess I wanted to try and catch most of them. Would you do that differently?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 can see recursive patching can become an issue when you have some submodules get patched but they are only called during app startup. I'm OK with an additional Django configuration parameter that create a segment that wraps the startup process. But IMO this should be opt-in as some users will not want to see dangling traces that just contains startup, and this is not an issue for users that don't use this feature.