Module: Sentry::Faraday::Connection

Defined in:
lib/sentry/faraday.rb

Instance Method Summary collapse

Instance Method Details

#initialize(url = nil, options = nil) ⇒ Object

Since there’s no way to preconfigure Faraday connections and add our instrumentation by default, we need to extend the connection constructor and do it there



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sentry/faraday.rb', line 12

def initialize(url = nil, options = nil)
  super

  # Ensure that we attach instrumentation only if the adapter is not net/http
  # because if is is, then the net/http instrumentation will take care of it
  if builder.adapter.name != "Faraday::Adapter::NetHttp"
    # Make sure that it's going to be the first middleware so that it can capture
    # the entire request processing involving other middlewares
    builder.insert(0, ::Faraday::Request::Instrumentation, name: OP_NAME, instrumenter: Instrumenter.new)
  end
end