Class: Datadog::OpenTracer::DistributedHeaders
- Inherits:
-
Object
- Object
- Datadog::OpenTracer::DistributedHeaders
- Defined in:
- lib/datadog/opentracer/distributed_headers.rb
Overview
DistributedHeaders provides easy access and validation to headers
Instance Method Summary collapse
-
#initialize(carrier) ⇒ DistributedHeaders
constructor
A new instance of DistributedHeaders.
- #origin ⇒ Object
- #parent_id ⇒ Object
- #sampling_priority ⇒ Object
- #trace_id ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(carrier) ⇒ DistributedHeaders
Returns a new instance of DistributedHeaders.
11 12 13 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 11 def initialize(carrier) @carrier = carrier end |
Instance Method Details
#origin ⇒ Object
40 41 42 43 44 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 40 def origin hdr = @carrier[Tracing::Distributed::Datadog::ORIGIN_KEY] # Only return the value if it is not an empty string hdr if hdr != '' end |
#parent_id ⇒ Object
24 25 26 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 24 def parent_id id Tracing::Distributed::Datadog::PARENT_ID_KEY end |
#sampling_priority ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 28 def sampling_priority hdr = @carrier[Tracing::Distributed::Datadog::SAMPLING_PRIORITY_KEY] # It's important to make a difference between no header, # and a header defined to zero. return unless hdr value = hdr.to_i return if value < 0 value end |
#trace_id ⇒ Object
20 21 22 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 20 def trace_id id Tracing::Distributed::Datadog::TRACE_ID_KEY end |
#valid? ⇒ Boolean
15 16 17 18 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 15 def valid? # Sampling priority is optional. !trace_id.nil? && !parent_id.nil? end |