Module: Datadog::Contrib::HTTP::CircuitBreaker
- Included in:
- Datadog::Contrib::HTTP
- Defined in:
- lib/ddtrace/contrib/http/circuit_breaker.rb
Overview
HTTP integration circuit breaker behavior For avoiding recursive traces.
Instance Method Summary collapse
-
#datadog_http_request?(request) ⇒ Boolean
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.
- #should_skip_distributed_tracing?(pin) ⇒ Boolean
- #should_skip_tracing?(request, tracer) ⇒ Boolean
Instance Method Details
#datadog_http_request?(request) ⇒ Boolean
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.
21 22 23 24 25 26 27 |
# File 'lib/ddtrace/contrib/http/circuit_breaker.rb', line 21 def datadog_http_request?(request) if request[Datadog::Ext::Transport::HTTP::HEADER_META_TRACER_VERSION] true else false end end |
#should_skip_distributed_tracing?(pin) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/ddtrace/contrib/http/circuit_breaker.rb', line 29 def should_skip_distributed_tracing?(pin) if pin.config && pin.config.key?(:distributed_tracing) return !pin.config[:distributed_tracing] end !Datadog.configuration[:http][:distributed_tracing] end |
#should_skip_tracing?(request, tracer) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ddtrace/contrib/http/circuit_breaker.rb', line 7 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 |