class Skylight::Core::Normalizers::ActionController::ProcessAction
Normalizer
for processing a Rails controller action
Constants
- CAT
Public Instance Methods
normalize(trace, _name, payload)
click to toggle source
@param trace [Skylight::Messages::Trace::Builder] @param name [String] ignored, only present to match API @param payload [Hash] @option payload [String] :controller Controller name @option payload [String] :action Action name @return [Array]
# File lib/skylight/core/normalizers/action_controller/process_action.rb, line 20 def normalize(trace, _name, payload) trace.endpoint = controller_action(payload) [CAT, trace.endpoint, nil] end
normalize_after(trace, _span, _name, payload)
click to toggle source
# File lib/skylight/core/normalizers/action_controller/process_action.rb, line 25 def normalize_after(trace, _span, _name, payload) return unless config.enable_segments? if (segment = segment_from_payload(payload)) trace.segment = segment end end
Private Instance Methods
controller_action(payload)
click to toggle source
# File lib/skylight/core/normalizers/action_controller/process_action.rb, line 35 def controller_action(payload) "#{payload[:controller]}##{payload[:action]}" end
segment_from_payload(payload)
click to toggle source
# File lib/skylight/core/normalizers/action_controller/process_action.rb, line 39 def segment_from_payload(payload) # Show 'error' if there's an unhandled exception or if the status is 4xx or 5xx return "error" if payload[:exception] || payload[:exception_object] segment_from_status(payload[:status]) || if payload[:sk_rendered_format] # We only show the variant if we actually have a format # We won't have a sk_rendered_format if it's a `head` outside of a `respond_to` block. [payload[:sk_rendered_format], payload[:sk_variant]].compact.flatten.join("+") end end
segment_from_status(status)
click to toggle source
# File lib/skylight/core/normalizers/action_controller/process_action.rb, line 49 def segment_from_status(status) case status when 304 "not modified" when (300..399) "redirect" when (400..599) "error" end end