Module: Datadog::Contrib::Faraday::Patcher
- Includes:
- Patcher
- Defined in:
- lib/ddtrace/contrib/faraday/patcher.rb
Overview
Patcher enables patching of ‘faraday’ module.
Defined Under Namespace
Classes: DeprecatedPin
Class Method Summary collapse
- .add_default_middleware! ⇒ Object
- .add_pin! ⇒ Object
- .get_option(option) ⇒ Object
- .patch ⇒ Object
- .register_middleware! ⇒ Object
- .target_version ⇒ Object
Methods included from Patcher
Class Method Details
.add_default_middleware! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ddtrace/contrib/faraday/patcher.rb', line 42 def add_default_middleware! if target_version >= Gem::Version.new('1.0.0') ::Faraday::Connection.send(:prepend, Connection) else ::Faraday::RackBuilder.send(:prepend, RackBuilder) end end |
.add_pin! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
50 51 52 |
# File 'lib/ddtrace/contrib/faraday/patcher.rb', line 50 def get_option(option) Datadog.configuration[:faraday].get_option(option) end |
.patch ⇒ Object
20 21 22 23 24 25 26 |
# 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! ⇒ Object
38 39 40 |
# File 'lib/ddtrace/contrib/faraday/patcher.rb', line 38 def register_middleware! ::Faraday::Middleware.register_middleware(ddtrace: Middleware) end |
.target_version ⇒ Object
16 17 18 |
# File 'lib/ddtrace/contrib/faraday/patcher.rb', line 16 def target_version Integration.version end |