module Honeycomb::W3CPropagation::MarshalTraceContext

Serialize trace headers

Public Class Methods

parse_faraday_env(_env, propagation_context) click to toggle source
# File lib/honeycomb/propagation/w3c.rb, line 61
def self.parse_faraday_env(_env, propagation_context)
  {
    "traceparent" => to_trace_header(propagation_context),
  }
end
to_trace_header(propagation_context) click to toggle source
# File lib/honeycomb/propagation/w3c.rb, line 67
def self.to_trace_header(propagation_context)
  trace_id = propagation_context.trace_id
  parent_id = propagation_context.parent_id
  # do not propagate malformed ids
  if trace_id =~ /^[A-Fa-f0-9]{32}$/ && parent_id =~ /^[A-Fa-f0-9]{16}$/
    return "00-#{trace_id}-#{parent_id}-01"
  end

  nil
end

Public Instance Methods

to_trace_header() click to toggle source
# File lib/honeycomb/propagation/w3c.rb, line 52
def to_trace_header
  # do not propagate malformed ids
  if trace.id =~ /^[A-Fa-f0-9]{32}$/ && id =~ /^[A-Fa-f0-9]{16}$/
    return "00-#{trace.id}-#{id}-01"
  end

  nil
end