Class: Skylight::Core::Probes::ActionController::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/action_controller.rb

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.

Instance Method Summary collapse

Instance Method Details

#installObject

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.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/skylight/core/probes/action_controller.rb', line 5

def install
  ::ActionController::Instrumentation.class_eval do
    private
      alias_method :append_info_to_payload_without_sk, :append_info_to_payload
      def append_info_to_payload(payload)
        append_info_to_payload_without_sk(payload)

        rendered_mime = begin
          if content_type.is_a?(Mime::Type)
            content_type
          elsif content_type.respond_to?(:to_s)
            type_str = content_type.to_s.split(';').first
            Mime::Type.lookup(type_str) unless type_str.blank?
          elsif respond_to?(:rendered_format) && rendered_format
            rendered_format
          end
        end

        payload[:sk_rendered_format] = rendered_mime.try(:ref)
        payload[:sk_variant] = request.respond_to?(:variant) ? request.variant : nil
      end
  end
end