Module: ClientApiBuilder::ActiveSupportNotifications

Defined in:
lib/client_api_builder/active_support_notifications.rb

Instance Method Summary collapse

Instance Method Details

#instrument_requestObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/client_api_builder/active_support_notifications.rb', line 8

def instrument_request
  start_time = Time.now
  error = nil
  result = nil
  ActiveSupport::Notifications.instrument('client_api_builder.request', client: self) do
    result = yield
  rescue StandardError => e
    # Use StandardError instead of Exception to allow SystemExit, Interrupt, etc. to propagate
    error = e
  end

  # Re-raise with original backtrace preserved
  raise(error, error.message, error.backtrace) if error

  result
ensure
  @total_request_time = Time.now - start_time
end