Sha256: 468cd73dad4edba112f4ae8535c2111231578086de5106b15babc7709c248aab

Contents?: true

Size: 1.12 KB

Versions: 33

Compression:

Stored size: 1.12 KB

Contents

require 'ddtrace/contrib/analytics'

module Datadog
  module Contrib
    module ActionPack
      # Common utilities for ActionPack
      module Utils
        def self.exception_is_error?(exception)
          if defined?(::ActionDispatch::ExceptionWrapper)
            # Gets the equivalent status code for the exception (not all are 5XX)
            # You can add custom errors via `config.action_dispatch.rescue_responses`
            status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
            # Only 5XX exceptions are actually errors (e.g. don't flag 404s)
            status.to_s.starts_with?('5')
          else
            true
          end
        end

        def self.set_analytics_sample_rate(span)
          if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
            Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
          end
        end

        class << self
          private

          def datadog_configuration
            Datadog.configuration[:action_pack]
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
ddtrace-0.48.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.47.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.46.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.45.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.44.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.43.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.42.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.41.0 lib/ddtrace/contrib/action_pack/utils.rb
ls-trace-0.2.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.40.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.39.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.38.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.37.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.36.0 lib/ddtrace/contrib/action_pack/utils.rb
ls-trace-0.1.2 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.35.2 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.35.1 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.35.0 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.34.2 lib/ddtrace/contrib/action_pack/utils.rb
ddtrace-0.34.1 lib/ddtrace/contrib/action_pack/utils.rb