Module: SignalFx::Tracing::Instrumenter::Faraday
- Defined in:
- lib/signalfx/tracing/instrumentation/faraday.rb
Class Method Summary collapse
- .instrument(opts = {}) ⇒ Object
-
.patch_initialize ⇒ Object
somewhat messy, but this lets connections be traced without manual configuration to use the middleware.
Class Method Details
.instrument(opts = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/signalfx/tracing/instrumentation/faraday.rb', line 10 def instrument(opts = {}) begin require 'faraday' rescue LoadError return end begin require 'faraday/tracer' rescue LoadError => e puts e. return end patch_initialize if !@instrumented @instrumented = true end |
.patch_initialize ⇒ Object
somewhat messy, but this lets connections be traced without manual configuration to use the middleware
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/signalfx/tracing/instrumentation/faraday.rb', line 30 def patch_initialize ::Faraday::Connection.module_eval do alias_method :initialize_original, :initialize def initialize(url = nil, = nil, &block) # initialize the connection as usual initialize_original(url, , &block) # before we let go, add the Faraday tracer to the beginning of the stack @builder.insert(0, ::Faraday::Tracer) end end end |