Skip to content
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

[PROF-10241] Extract profiler at_fork monkey patch to utils #3829

Merged
merged 13 commits into from
Aug 7, 2024

Commits on Aug 7, 2024

  1. Configuration menu
    Copy the full SHA
    4ef6a14 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b41e2f2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    49e9f1c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    073ba72 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8351f66 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e5b4d07 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f1b8b80 View commit details
    Browse the repository at this point in the history
  8. Remove typechecking skeleton

    This typechecking skeleton doesn't actually work, so let's remove
    it until we can write a proper one.
    ivoanjo committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    699af6b View commit details
    Browse the repository at this point in the history
  9. [PROF-10241] Extract profiler at_fork monkey patch to utils

    **What does this PR do?**
    
    This PR extracts the profiler `Datadog::Profiling::Ext::Forking` monkey
    patch to now live under `Datadog::Core::Utils::AtForkMonkeyPatch`.
    
    It also does a clean up pass on some of the comments and specs, as well
    as rename some of the modules used for the actual monkey patching.
    
    **Motivation:**
    
    This monkey patch provides a `datadog_at_fork` mechanism that
    can be used to run code just after a process gets forked.
    
    Here's a quick example:
    
    ```ruby
    $ bundle exec pry
    [1] pry(main)> require 'datadog/core/utils/at_fork_monkey_patch'
    => true
    [2] pry(main)> Datadog::Core::Utils::AtForkMonkeyPatch.apply!
    => true
    [3] pry(main)> Process.datadog_at_fork(:child) { puts "This code is running in a child process!" }
    => nil
    [4] pry(main)> fork { puts "Hello from fork" }
    This code is running in a child process!
    Hello from fork
    => 447306
    ```
    
    Up until now, only the profiler needed this behavior of getting
    auto-started right after a process forks.
    
    Every other component of ddtrace lazily waited until it got called
    again (e.g. the tracing bits would not get re-initialized until
    you tried to call the tracer).
    
    With the introduction of the crashtracker, we also want the
    crashtracker to auto-start after a fork, so I'm extracing the
    monkey patch so we can use it on that component as well.
    
    **Additional Notes:**
    
    I'm preparing a follow-up PR to add support for `Process._fork`.
    It's been a long time coming, and it's not that big of a change.
    
    **How to test the change?**
    
    Our existing specs already cover this change. Also see the example
    above.
    ivoanjo committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    9f1d53d View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    216bc8b View commit details
    Browse the repository at this point in the history
  11. Update Steepfile

    ivoanjo committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    480fcf0 View commit details
    Browse the repository at this point in the history
  12. Rubocop fixes

    ivoanjo committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    473833b View commit details
    Browse the repository at this point in the history
  13. Minor: Bootstrap empty rbs file

    I did not realize we had a check for this ;)
    ivoanjo committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    4c69eb3 View commit details
    Browse the repository at this point in the history