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 42 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.send(: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.send(:prepend, RackBuilder) end end
add_pin!()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 28 def add_pin! DeprecatedPin .new( get_option(:service_name), app: Ext::APP, app_type: Datadog::Ext::AppTypes::WEB, tracer: -> { get_option(:tracer) } ).onto(::Faraday) end
get_option(option)
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 62 def get_option(option) Datadog.configuration[:faraday].get_option(option) end
patch()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 20 def patch require 'ddtrace/contrib/faraday/middleware' add_pin! register_middleware! add_default_middleware! end
register_middleware!()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 38 def register_middleware! ::Faraday::Middleware.register_middleware(ddtrace: Middleware) end
target_version()
click to toggle source
# File lib/ddtrace/contrib/faraday/patcher.rb, line 16 def target_version Integration.version end