Method: Datadog::Contrib::ActionPack::ActionController::Instrumentation::Metal#process_action

Defined in:
lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb

#process_action(*args) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb', line 95

def process_action(*args)
  # mutable payload with a tracing context that is used in two different
  # signals; it propagates the request span so that it can be finished
  # no matter what
  payload = {
    controller: self.class,
    action: action_name,
    env: request.env,
    headers: {
      # The exception this controller was given in the request,
      # which is typical if the controller is configured to handle exceptions.
      request_exception: request.headers['action_dispatch.exception']
    },
    tracing_context: {}
  }

  begin
    # process and catch request exceptions
    Instrumentation.start_processing(payload)
    result = super(*args)
    status = datadog_response_status
    payload[:status] = status unless status.nil?
    result
  # rubocop:disable Lint/RescueException
  rescue Exception => e
    payload[:exception] = [e.class.name, e.message]
    payload[:exception_object] = e
    raise e
  end
# rubocop:enable Lint/RescueException
ensure
  Instrumentation.finish_processing(payload)
end