Sha256: 5a54b1e4798486946a784bdf43a95d195987de1032a91d27e3178458b179a36c

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

# typed: true
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

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.54.2 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.54.1 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.54.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.53.0 lib/ddtrace/contrib/http/circuit_breaker.rb
ddtrace-0.52.0 lib/ddtrace/contrib/http/circuit_breaker.rb