module Datadog::Contrib::Faraday::Patcher
Patcher
enables patching of 'faraday' module.
Public Instance Methods
add_default_middleware!()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 32 def add_default_middleware! if target_version >= Gem::Version.new('1.0.0') # Patch the default connection (e.g. +Faraday.get+) ::Faraday.default_connection.use(:ddtrace) # Patch new connection instances (e.g. +Faraday.new+) ::Faraday::Connection.prepend(Connection) else # Patch the default connection (e.g. +Faraday.get+) # # We insert our middleware before the 'adapter', which is # always the last handler. idx = ::Faraday.default_connection.builder.handlers.size - 1 ::Faraday.default_connection.builder.insert(idx, Middleware) # Patch new connection instances (e.g. +Faraday.new+) ::Faraday::RackBuilder.prepend(RackBuilder) end end
patch()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 21 def patch require 'ddtrace/contrib/faraday/middleware' register_middleware! add_default_middleware! end
register_middleware!()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 28 def register_middleware! ::Faraday::Middleware.register_middleware(ddtrace: Middleware) end
target_version()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 17 def target_version Integration.version end