Module: Datadog::Tracing::Contrib::ActionPack::ActionController::Instrumentation::Metal
- Defined in:
- lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb
Overview
Instrumentation for ActionController::Metal
Instance Method Summary collapse
- #datadog_response_status ⇒ Object
-
#process_action(*args) ⇒ Object
TODO: Refactor this method to avoid using async API that splits the logic into two different methods (‘start_processing` and `finish_processing`).
Instance Method Details
#datadog_response_status ⇒ Object
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb', line 142 def datadog_response_status case response when ::ActionDispatch::Response response.status when Array # Likely a Rack response array: first element is the status. status = response.first status.class <= Integer ? status : nil end end |
#process_action(*args) ⇒ Object
TODO: Refactor this method to avoid using async API that splits the logic into two different methods (‘start_processing` and `finish_processing`)
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 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb', line 99 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.] payload[:exception_object] = e raise e ensure # Database and view runtime are available for controllers # deriving from ActionController::Base. # They are not defined on controllers deriving from # ActionController::Metal, unless # ActionController::Instrumentation is explicitly included # into the controller class. payload[:db_runtime] = db_runtime if respond_to?(:db_runtime) payload[:view_runtime] = view_runtime if respond_to?(:view_runtime) end # rubocop:enable Lint/RescueException ensure Instrumentation.finish_processing(payload) end |