Sha256: 0e81344a9c27b8019e44410e41f0784d8e6801328ebedf245d86d928c00973b0
Contents?: true
Size: 1.28 KB
Versions: 22
Compression:
Stored size: 1.28 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) # Prevent propagation from being attempted if context provided is nil. if context.nil? Datadog::Tracer.log.debug('Cannot inject context into env to propagate over HTTP: context is nil.'.freeze) return end 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
22 entries across 22 versions & 1 rubygems