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.
9 10 11 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 9 def initialize(carrier) @carrier = carrier end |
Instance Method Details
#origin ⇒ Object
38 39 40 41 42 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 38 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
22 23 24 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 22 def parent_id id Tracing::Distributed::Datadog::PARENT_ID_KEY end |
#sampling_priority ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 26 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
18 19 20 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 18 def trace_id id Tracing::Distributed::Datadog::TRACE_ID_KEY end |
#valid? ⇒ Boolean
13 14 15 16 |
# File 'lib/datadog/opentracer/distributed_headers.rb', line 13 def valid? # Sampling priority is optional. !trace_id.nil? && !parent_id.nil? end |