Module: BrainzLab::Instrumentation::HTTPartyInstrumentation::Patch

Defined in:
lib/brainzlab/instrumentation/httparty.rb

Instance Method Summary collapse

Instance Method Details

#perform_request(http_method, path, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/brainzlab/instrumentation/httparty.rb', line 29

def perform_request(http_method, path, options = {}, &)
  return super unless should_track?(path, options)

  # Inject distributed tracing headers
  options = inject_trace_context(options)

  started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)

  begin
    response = super
    track_request(http_method, path, options, response.code, started_at)
    response
  rescue StandardError => e
    error_info = e.class.name
    track_request(http_method, path, options, nil, started_at, error_info)
    raise
  end
end