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

Improve clearing of profile data after Ruby app forks #2362

Merged
merged 6 commits into from
Nov 16, 2022

Commits on Nov 10, 2022

  1. Refactor hacky exporter.flush after process fork into exporter.clear

    Calling `exporter.flush` after fork to clear any existing profiling
    data works, but it's rather heavy-handed and can generate a few
    confusing log messages:
    
    ```
    DEBUG (dd-trace-rb/lib/datadog/profiling/scheduler.rb:73:in `after_fork') Flushing exporter in child process #after_fork and discarding data
    DEBUG (dd-trace-rb/lib/datadog/profiling/stack_recorder.rb:25:in `serialize') Encoded profile covering 2022-11-10T09:42:22Z to 2022-11-10T09:42:22Z
    DEBUG (dd-trace-rb/lib/datadog/profiling/exporter.rb:52:in `flush') Skipped exporting profiling events as profile duration is below minimum
    ```
    
    To improve this, I've cleared a new `Exporter#clear` that is still
    (currently) implemented using `flush`, but now the exporter knows
    what's going on more explicitly, and so it can implement `clear`
    in a better way.
    ivoanjo committed Nov 10, 2022
    Configuration menu
    Copy the full SHA
    82a9558 View commit details
    Browse the repository at this point in the history
  2. Improve Exporter#clear by extracting only the operations actually n…

    …eeded
    
    The previous `flush` call was a placeholder, and we can now improve it.
    ivoanjo committed Nov 10, 2022
    Configuration menu
    Copy the full SHA
    35e0bbe View commit details
    Browse the repository at this point in the history
  3. Add StackRecorder#clear

    This will be used by the `Exporter` when needing to clear data without
    serializing it.
    ivoanjo committed Nov 10, 2022
    Configuration menu
    Copy the full SHA
    ad10f75 View commit details
    Browse the repository at this point in the history
  4. Use StackRecorder#clear in Exporter

    As the `StackRecorder` implements `#clear` natively, no need to
    simulate it with a call to `#serialize`.
    
    I decided not to bother updating the `OldRecorder`, so for that
    class we'll still use the old behavior.
    ivoanjo committed Nov 10, 2022
    Configuration menu
    Copy the full SHA
    d369843 View commit details
    Browse the repository at this point in the history

Commits on Nov 11, 2022

  1. Configuration menu
    Copy the full SHA
    1f2fdf5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    96acfb2 View commit details
    Browse the repository at this point in the history