Sha256: a655b75ba4251ec1bb29ab26cbd552e625cb46f0b173e1b1b11c8e9cda700204

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require "sentry/rails/tracing/abstract_subscriber"
require "sentry/rails/instrument_payload_cleanup_helper"

module Sentry
  module Rails
    module Tracing
      class ActionControllerSubscriber < AbstractSubscriber
        extend InstrumentPayloadCleanupHelper

        EVENT_NAMES = ["process_action.action_controller"].freeze
        OP_NAME = "view.process_action.action_controller".freeze

        def self.subscribe!
          subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
            controller = payload[:controller]
            action = payload[:action]

            record_on_current_span(
              op: OP_NAME,
              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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-rails-5.7.0 lib/sentry/rails/tracing/action_controller_subscriber.rb
sentry-rails-5.6.0 lib/sentry/rails/tracing/action_controller_subscriber.rb