Sha256: 6978192ef8f991c7b7e49e7effcb49d707361e85fc14ddb88e7cfa3ece43b269

Contents?: true

Size: 1.2 KB

Versions: 24

Compression:

Stored size: 1.2 KB

Contents

require_relative '../analytics'

module Datadog
  module Tracing
    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.start_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.tracing[:action_pack]
            end
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ddtrace-1.23.3 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.16.2 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.16.1 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.16.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.15.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.14.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.13.1 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.13.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.12.1 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/action_pack/utils.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/action_pack/utils.rb