Sha256: 9433b0f6093e264e9c7ea743e994d016610dacb7263274b5ccbccfd4ec148e3f
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
require 'ddtrace/span' require 'ddtrace/ext/distributed' module Datadog module OpenTracer # DistributedHeaders provides easy access and validation to headers class DistributedHeaders include Datadog::Ext::DistributedTracing def initialize(carrier) @carrier = carrier end def valid? # Sampling priority is optional. !trace_id.nil? && !parent_id.nil? end def trace_id id HTTP_HEADER_TRACE_ID end def parent_id id HTTP_HEADER_PARENT_ID end 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 private def id(header) value = @carrier[header].to_i return if value.zero? || value >= Datadog::Span::MAX_ID value < 0 ? value + 0x1_0000_0000_0000_0000 : value end end end end
Version data entries
12 entries across 12 versions & 1 rubygems