class Datadog::OpenTracer::DistributedHeaders
DistributedHeaders
provides easy access and validation to headers
Public Class Methods
new(carrier)
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 11 def initialize(carrier) @carrier = carrier end
Public Instance Methods
origin()
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 40 def origin hdr = @carrier[HTTP_HEADER_ORIGIN] # Only return the value if it is not an empty string hdr if hdr != '' end
parent_id()
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 24 def parent_id id HTTP_HEADER_PARENT_ID end
sampling_priority()
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 28 def sampling_priority hdr = @carrier[HTTP_HEADER_SAMPLING_PRIORITY] # 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()
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 20 def trace_id id HTTP_HEADER_TRACE_ID end
valid?()
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 15 def valid? # Sampling priority is optional. !trace_id.nil? && !parent_id.nil? end
Private Instance Methods
id(header)
click to toggle source
# File lib/ddtrace/opentracer/distributed_headers.rb, line 48 def id(header) value = @carrier[header].to_i return if value.zero? || value >= Datadog::Span::EXTERNAL_MAX_ID value < 0 ? value + 0x1_0000_0000_0000_0000 : value end