Sha256: d596dfd8d2ab722f242a043eada634794ae982a990e5c3d1cd8f67aa7c616e04

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

module Datadog
  module Contrib
    module HTTP
      # HTTP integration circuit breaker behavior
      # For avoiding recursive traces.
      module CircuitBreaker
        def should_skip_tracing?(request, tracer)
          return true if datadog_http_request?(request)

          # we don't want a "shotgun" effect with two nested traces for one
          # logical get, and request is likely to call itself recursively
          active = tracer.active_span
          return true if active && (active.name == Ext::SPAN_REQUEST)

          false
        end

        # We don't want to trace our own call to the API (they use net/http)
        # TODO: We don't want this kind of soft-check on HTTP requests.
        #       Remove this when transport implements its own "skip tracing" mechanism.
        def datadog_http_request?(request)
          if request[Datadog::Ext::Transport::HTTP::HEADER_META_TRACER_VERSION]
            true
          else
            false
          end
        end

        def should_skip_distributed_tracing?(pin)
          return !pin.config[:distributed_tracing] if pin.config && pin.config.key?(:distributed_tracing)

          !Datadog.configuration[:http][:distributed_tracing]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.51.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.50.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.49.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.48.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.47.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.46.0 lib/ddtrace/contrib/http/circuit_breaker.rb