Sha256: 144c8e229c42dbeca13e2cae8c131ab7274dd7df97b478eb873cd01b9722d4b6

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

require 'ddtrace/context'
require 'ddtrace/ext/distributed'
require 'ddtrace/propagation/distributed_headers'

module Datadog
  # HTTPPropagator helps extracting and injecting HTTP headers.
  module HTTPPropagator
    include Ext::DistributedTracing

    # inject! popolates the env with span ID, trace ID and sampling priority
    def self.inject!(context, env)
      env[HTTP_HEADER_TRACE_ID] = context.trace_id.to_s
      env[HTTP_HEADER_PARENT_ID] = context.span_id.to_s
      env[HTTP_HEADER_SAMPLING_PRIORITY] = context.sampling_priority.to_s
      env.delete(HTTP_HEADER_SAMPLING_PRIORITY) unless context.sampling_priority
    end

    # extract returns a context containing the span ID, trace ID and
    # sampling priority defined in env.
    def self.extract(env)
      headers = DistributedHeaders.new(env)
      return Datadog::Context.new unless headers.valid?
      Datadog::Context.new(trace_id: headers.trace_id,
                           span_id: headers.parent_id,
                           sampling_priority: headers.sampling_priority)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ddtrace-0.14.0.beta2 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.14.0.beta1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.13.1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.13.0 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.12.1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.13.0.beta1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.12.0 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.12.0.rc1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.4 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.3 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.12.0.beta2 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.12.0.beta1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.2 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.0 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.0.beta2 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.11.0.beta1 lib/ddtrace/propagation/http_propagator.rb
ddtrace-0.10.0 lib/ddtrace/propagation/http_propagator.rb