[PROF-4756] Simplify profiling Forking
monkey patch, making it less generic
#2149
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.
What does this PR do?:
Simplify the profiling
Forking
monkey patch, by removed the unused:prepare
and:parent
stages for callbacks.Motivation:
The profiling
Forking
monkey patch only has a single customer: theDatadog::Profiling::Tasks::Setup
class, which uses it to add anat_fork(:child)
that takes care of restarting the profiler and fixing up the thread ids after a fork happened.Since the
Forking
monkey patch affects core Ruby classes, I decided to simplify it, as we're not using the added complexity, and I prefer it being as simple as possible.My additional motivation is that I'm working on support for monkey patching
Process.daemon
, and this simplifies the amount of code and tests needed to implement the needed functionality.(We can always undo this if later we find a need for the other callbacks, but in the ~2 years of life of this monkey patch, we haven't needed the extra functionality, so I'll take that as a signal).
How to test the change?:
DD_PROFILING_ENABLED=true DD_TRACE_DEBUG=true bundle exec ddtracerb exec ruby -e 'fork { sleep }; sleep'
) and validate that the profiler successfully restarts in the child process after thefork