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
55 56 57 |
# File 'lib/ddtrace/monkey.rb', line 55 def autopatch_modules @autopatch_modules.clone end |
.get_patched_modules ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ddtrace/monkey.rb', line 77 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
71 72 73 74 75 |
# File 'lib/ddtrace/monkey.rb', line 71 def patch(modules) modules.each do |k, v| patch_module(k) if v end end |
.patch_all ⇒ Object
59 60 61 |
# File 'lib/ddtrace/monkey.rb', line 59 def patch_all patch @autopatch_modules end |
.patch_module(m) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/ddtrace/monkey.rb', line 63 def patch_module(m) @mutex.synchronize do patcher = @patchers[m] raise "Unsupported module #{m}" unless patcher patcher.patch end end |
.without_warnings ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ddtrace/monkey.rb', line 90 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 |