Module: RailsTwirp::Instrumentation

Extended by:
ActiveSupport::Concern
Includes:
AbstractController::Logger
Included in:
Base
Defined in:
lib/rails_twirp/instrumentation.rb

Instance Method Summary collapse

Instance Method Details

#process_actionObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rails_twirp/instrumentation.rb', line 9

def process_action(*)
  raw_payload = {
    controller: self.class.name,
    action: action_name,
    request: request,
    http_request: http_request,
    headers: http_request.headers,
    path: http_request.fullpath
  }

  ActiveSupport::Notifications.instrument("start_processing.rails_twirp", raw_payload)

  ActiveSupport::Notifications.instrument("process_action.rails_twirp", raw_payload) do |payload|
    result = super
    if response_body.is_a?(Twirp::Error)
      payload[:code] = response_body.code
      payload[:msg] = response_body.msg
    else
      payload[:code] = :success
    end
    payload[:response] = response_body
    result
  end
end