Class: Sentry::Excon::Instrumenter

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

Constant Summary collapse

SPAN_ORIGIN =
"auto.http.excon"
"http"

Instance Method Summary collapse

Instance Method Details

#finish_transaction(response) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/sentry/excon/middleware.rb', line 43

def finish_transaction(response)
  return unless @span

  response_status = response[:response][:status]
  request_info = extract_request_info(response)

  if record_sentry_breadcrumb?
    record_sentry_breadcrumb(request_info, response_status)
  end

  set_span_info(@span, request_info, response_status)
ensure
  @span&.finish
end

#start_transaction(env) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sentry/excon/middleware.rb', line 30

def start_transaction(env)
  return unless Sentry.initialized?

  current_span = Sentry.get_current_scope&.span
  @span = current_span&.start_child(op: OP_NAME, start_timestamp: Sentry.utc_now.to_f, origin: SPAN_ORIGIN)

  request_info = extract_request_info(env)

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