module Datadog::GRPCPropagator

opentracing.io compliant methods for distributing trace context between two or more distributed services. Note this is very close to the HTTPPropagator; the key difference is the way gRPC handles header information (called “metadata”) as it operates over HTTP2

Public Class Methods

extract(metadata) click to toggle source
# File lib/ddtrace/propagation/grpc_propagator.rb, line 20
def self.extract(metadata)
  metadata = Carrier.new(metadata)
  return Datadog::Context.new unless metadata.valid?

  Datadog::Context.new(trace_id: metadata.trace_id,
                       span_id: metadata.parent_id,
                       sampling_priority: metadata.sampling_priority,
                       origin: metadata.origin)
end
inject!(context, metadata) click to toggle source
# File lib/ddtrace/propagation/grpc_propagator.rb, line 13
def self.inject!(context, metadata)
  metadata[GRPC_METADATA_TRACE_ID] = context.trace_id.to_s
  metadata[GRPC_METADATA_PARENT_ID] = context.span_id.to_s
  metadata[GRPC_METADATA_SAMPLING_PRIORITY] = context.sampling_priority.to_s if context.sampling_priority
  metadata[GRPC_METADATA_ORIGIN] = context.origin.to_s if context.origin
end