module SignalFx::Tracing::Instrumenter::Faraday
Public Class Methods
initialize(url = nil, options = nil, &block)
click to toggle source
# File lib/signalfx/tracing/instrumentation/faraday.rb, line 34 def initialize(url = nil, options = nil, &block) # initialize the connection as usual initialize_original(url, options, &block) # before we let go, add the Faraday tracer to the beginning of the stack @builder.insert(0, ::Faraday::Tracer) end
instrument(opts = {})
click to toggle source
# 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.message return end patch_initialize if !@instrumented @instrumented = true end
patch_initialize()
click to toggle source
somewhat messy, but this lets connections be traced without manual configuration to use the middleware
# 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, options = nil, &block) # initialize the connection as usual initialize_original(url, options, &block) # before we let go, add the Faraday tracer to the beginning of the stack @builder.insert(0, ::Faraday::Tracer) end end end