Class: Sentry::Rails::Tracing::ActionControllerSubscriber

Inherits:
AbstractSubscriber show all
Extended by:
InstrumentPayloadCleanupHelper
Defined in:
lib/sentry/rails/tracing/action_controller_subscriber.rb

Constant Summary collapse

EVENT_NAMES =
["process_action.action_controller"].freeze
OP_NAME =
"view.process_action.action_controller"
SPAN_ORIGIN =
"auto.view.rails"

Constants included from InstrumentPayloadCleanupHelper

InstrumentPayloadCleanupHelper::IGNORED_DATA_TYPES

Class Method Summary collapse

Methods included from InstrumentPayloadCleanupHelper

cleanup_data

Methods inherited from AbstractSubscriber

record_on_current_span, #subscribe_to_event, unsubscribe!

Class Method Details

.subscribe!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sentry/rails/tracing/action_controller_subscriber.rb', line 16

def self.subscribe!
  Sentry.logger.warn <<~MSG
    DEPRECATION WARNING: sentry-rails has changed its approach on controller span recording and #{self.name} is now depreacted.
    Please stop using or referencing #{self.name} as it will be removed in the next major release.
  MSG

  subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
    controller = payload[:controller]
    action = payload[:action]

    record_on_current_span(
      op: OP_NAME,
      origin: SPAN_ORIGIN,
      start_timestamp: payload[START_TIMESTAMP_NAME],
      description: "#{controller}##{action}",
      duration: duration
    ) do |span|
      payload = payload.dup
      cleanup_data(payload)
      span.set_data(:payload, payload)
      span.set_http_status(payload[:status])
    end
  end
end