Module: Datadog::Monkey
- Defined in:
- lib/ddtrace/monkey.rb
Overview
Monkey is used for monkey-patching 3rd party libs.
Class Method Summary collapse
- .autopatch_modules ⇒ Object
- .get_patched_modules ⇒ Object
- .patch(modules) ⇒ Object
- .patch_all ⇒ Object
- .patch_module(m) ⇒ Object
- .without_warnings ⇒ Object
Class Method Details
.autopatch_modules ⇒ Object
37 38 39 |
# File 'lib/ddtrace/monkey.rb', line 37 def autopatch_modules @autopatch_modules.clone end |
.get_patched_modules ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ddtrace/monkey.rb', line 59 def get_patched_modules patched = autopatch_modules @patchers.each do |k, v| @mutex.synchronize do if v patcher = @patchers[k] patched[k] = patcher.patched? if patcher end end end patched end |
.patch(modules) ⇒ Object
53 54 55 56 57 |
# File 'lib/ddtrace/monkey.rb', line 53 def patch(modules) modules.each do |k, v| patch_module(k) if v end end |
.patch_all ⇒ Object
41 42 43 |
# File 'lib/ddtrace/monkey.rb', line 41 def patch_all patch @autopatch_modules end |
.patch_module(m) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/ddtrace/monkey.rb', line 45 def patch_module(m) @mutex.synchronize do patcher = @patchers[m] raise "Unsupported module #{m}" unless patcher patcher.patch end end |
.without_warnings ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ddtrace/monkey.rb', line 72 def without_warnings # This is typically used when monkey patching functions such as # intialize, which Ruby advices you not to. Use cautiously. v = $VERBOSE $VERBOSE = nil begin yield ensure $VERBOSE = v end end |