Module: Chronos::Integrations::NetHttp
- Defined in:
- lib/chronos/integrations/net_http.rb
Overview
Optional per-instance Net::HTTP instrumentation without a global monkey patch.
Defined Under Namespace
Modules: InstrumentedRequest
Constant Summary collapse
- INSTALLED_KEY =
:@__chronos_net_http_installed- OPTIONS_KEY =
:@__chronos_net_http_options
Class Method Summary collapse
Class Method Details
.install(connection, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/chronos/integrations/net_http.rb', line 20 def install(connection, = {}) notifier = [:notifier] || Chronos return false unless enabled?(notifier) return false unless connection.respond_to?(:request) && connection.respond_to?(:address) mutex_for(connection).synchronize do return false if connection.instance_variable_get(INSTALLED_KEY) connection.instance_variable_set(OPTIONS_KEY, (notifier, )) connection.singleton_class.send(:prepend, InstrumentedRequest) connection.instance_variable_set(INSTALLED_KEY, true) end true rescue StandardError false end |