class Gruf::Lightstep::Headers

Abstraction accessor class for B3 propagation headers across GRPC ActiveCall objects

Constants

OT_KEYS

@property [Hash<Symbol|Array<String>>] Hash mapping of metadata keys

Attributes

active_call[R]

Public Class Methods

new(active_call) click to toggle source

@param [GRPC::ActiveCall] active_call

# File lib/gruf/lightstep/headers.rb, line 42
def initialize(active_call)
  @active_call = active_call
end

Public Instance Methods

metadata() click to toggle source

@return [Hash]

# File lib/gruf/lightstep/headers.rb, line 64
def metadata
  @active_call.metadata
end
to_h() click to toggle source

@return [Hash]

# File lib/gruf/lightstep/headers.rb, line 71
def to_h
  @active_call.metadata
end
value(key) click to toggle source

Return a B3 propagation header if present

@param [Symbol] key @return [String|NilClass]

# File lib/gruf/lightstep/headers.rb, line 52
def value(key)
  return nil unless OT_KEYS.key?(key)

  OT_KEYS[key].each do |k|
    return metadata[k] if metadata.key?(k)
  end
  nil
end