Class: Sentry::Faraday::Instrumenter

Inherits:
Object
  • Object
show all
Includes:
Utils::HttpTracing
Defined in:
lib/sentry/faraday.rb

Constant Summary collapse

SPAN_ORIGIN =
"auto.http.faraday"
"http"

Instance Method Summary collapse

Instance Method Details

#instrument(op_name, env, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sentry/faraday.rb', line 31

def instrument(op_name, env, &block)
  return block.call unless Sentry.initialized?

  Sentry.with_child_span(op: op_name, start_timestamp: Sentry.utc_now.to_f, origin: SPAN_ORIGIN) do |sentry_span|
    request_info = extract_request_info(env)

    if propagate_trace?(request_info[:url])
      set_propagation_headers(env[:request_headers])
    end

    res = block.call
    response_status = res.status

    if record_sentry_breadcrumb?
      record_sentry_breadcrumb(request_info, response_status)
    end

    if sentry_span
      set_span_info(sentry_span, request_info, response_status)
    end

    res
  end
end