Module: BaselineRedRpm::Instruments::TyphoeusRequest

Defined in:
lib/baseline_red_rpm/instruments/typhoeus.rb

Instance Method Summary collapse

Instance Method Details

#run_with_traceObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/baseline_red_rpm/instruments/typhoeus.rb', line 6

def run_with_trace
  if ::BaselineRedRpm::Tracer.tracing?
    span = ::BaselineRedRpm.tracer.start_span("typhoeus", tags: {
      "component" => "Typhoeus"
    })
    BaselineRedRpm.tracer.inject(span.context, OpenTracing::FORMAT_RACK, options[:headers])

    response = run_without_trace
    span.exit
    uri = URI(response.effective_url)

    span.set_tag "http.status_code", response.code
    span.set_tag "http.url", uri.to_s
    span.set_tag "http.method", options[:method]
    BaselineRedRpm::Utils.log_source_and_backtrace(span, :typhoeus)
  else
    response = run_without_trace
  end
  response
rescue Exception => e
  if span
    span.set_tag('error', true)
    span.log_error(e)
  end
  raise
ensure
  span.finish if span
end