Module: Datadog::Profiling::Ext::DirMonkeyPatches

Defined in:
lib/datadog/profiling/ext/dir_monkey_patches.rb

Overview

All Ruby versions as of this writing have bugs in the dir class implementation, causing issues such as github.com/DataDog/dd-trace-rb/issues/3450 . See also bugs.ruby-lang.org/issues/20586 for more details.

This monkey patch for the Ruby ‘Dir` class works around these bugs for affected Ruby versions by temporarily blocking the profiler from interrupting system calls.

A lot of these APIs do very similar things – they’re provided by Ruby as helpers so users don’t need to keep reimplementing them but share the same underlying buggy code. And so our monkey patches are a bit repetitive as well. We don’t DRY out this file to have minimal overhead.

These monkey patches are applied by the profiler when the “dir_interruption_workaround_enabled” setting is enabled. See the profiling settings for more detail.

Class Method Summary collapse

Class Method Details

.apply!Object



22
23
24
25
26
27
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 22

def self.apply!
  ::Dir.singleton_class.prepend(Datadog::Profiling::Ext::DirClassMonkeyPatches)
  ::Dir.prepend(Datadog::Profiling::Ext::DirInstanceMonkeyPatches)

  true
end