Sha256: 237205073f4da1344556d27b71bf27d20a1eda6b6078749a7b62185ff855ab85

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module Sentry
  module Rails
    module ControllerTransaction
      SPAN_ORIGIN = "auto.view.rails".freeze

      def self.included(base)
        base.prepend_around_action(:sentry_around_action)
      end

      private

      def sentry_around_action
        if Sentry.initialized?
          transaction_name = "#{self.class}##{action_name}"
          Sentry.get_current_scope.set_transaction_name(transaction_name, source: :view)
          Sentry.with_child_span(op: "view.process_action.action_controller", description: transaction_name, origin: SPAN_ORIGIN) do |child_span|
            if child_span
              begin
                result = yield
              ensure
                child_span.set_http_status(response.status)
                child_span.set_data(:format, request.format)
                child_span.set_data(:method, request.method)
                child_span.set_data(:path, request.path)
                child_span.set_data(:params, request.params)
              end

              result
            else
              yield
            end
          end
        else
          yield
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-rails-5.20.1 lib/sentry/rails/controller_transaction.rb
sentry-rails-5.20.0 lib/sentry/rails/controller_transaction.rb