Class: Skylight::Core::Normalizers::ActionController::ProcessAction Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/skylight/core/normalizers/action_controller/process_action.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Normalizer for processing a Rails controller action

Constant Summary collapse

CAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"app.controller.request".freeze

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, register

Constructor Details

This class inherits a constructor from Skylight::Core::Normalizers::Normalizer

Instance Method Details

#normalize(trace, name, payload) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • trace (Skylight::Messages::Trace::Builder)
  • name (String)

    ignored, only present to match API

  • payload (Hash)

Options Hash (payload):

  • :controller (String)

    Controller name

  • :action (String)

    Action name

Returns:

  • (Array)


20
21
22
23
# 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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/skylight/core/normalizers/action_controller/process_action.rb', line 25

def normalize_after(trace, span, name, payload)
  return unless config.enable_segments?

  # Show 'error' if there's an unhandled exception or if the status is 4xx or 5xx
  if payload[:exception] || payload[:exception_object] || payload[:status].to_s =~ /^[45]/
    segment = "error"
  # We won't have a rendered_format if it's a `head` outside of a `respond_to` block.
  elsif payload[:rendered_format]
    # We only show the variant if we actually have a format
    segment = [payload[:rendered_format], payload[:variant]].compact.flatten.join('+')
  end

  if segment
    trace.endpoint += "<sk-segment>#{segment}</sk-segment>"
  end
end