class Sentry::Baggage

A {www.w3.org/TR/baggage W3C Baggage Header} implementation.

def self.from_incoming_header(header)

Returns:
  • (Baggage, nil) -

Parameters:
  • header (String) -- The incoming Baggage header string.
def self.from_incoming_header(header)
  items = {}
  mutable = true
  header.split(',').each do |item|
    item = item.strip
    key, val = item.split('=')
    next unless key && val
    next unless key =~ SENTRY_PREFIX_REGEX
    baggage_key = key.split('-')[1]
    next unless baggage_key
    items[CGI.unescape(baggage_key)] = CGI.unescape(val)
    mutable = false
  end
  new(items, mutable: mutable)
end

def dynamic_sampling_context

Returns:
  • (Hash) -
def dynamic_sampling_context
  @items
end

def freeze!

Returns:
  • (void) -
def freeze!
  @mutable = false
end

def initialize(items, mutable: true)

def initialize(items, mutable: true)
  @items = items
  @mutable = mutable
end

def serialize

Returns:
  • (String) -
def serialize
  items = @items.map { |k, v| "#{SENTRY_PREFIX}#{CGI.escape(k)}=#{CGI.escape(v)}" }
  items.join(',')
end