Class: Gruf::Lightstep::Headers

Inherits:
Object
  • Object
show all
Defined in:
lib/gruf/lightstep/headers.rb

Overview

Abstraction accessor class for B3 propagation headers across GRPC ActiveCall objects

Constant Summary collapse

OT_KEYS =
{
  parent_span_id: %w[ot-tracer-parentspanid OT-Tracer-ParentSpanId HTTP_X_OT_TRACER_PARENTSPANID],
  span_id: %w[ot-tracer-spanid OT-Tracer-SpanId HTTP_X_OT_TRACER_SPANID],
  trace_id: %w[ot-tracer-traceid OT-Tracer-TraceId HTTP_X_OT_TRACER_TRACEID],
  sampled: %w[ot-tracer-sampled OT-Tracer-Sampled HTTP_X_OT_TRACER_SAMPLED],
  flags: %w[ot-tracer-flags OT-Tracer-Flags HTTP_X_OT_TRACER_FLAGS]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_call) ⇒ Headers

Returns a new instance of Headers.

Parameters:

  • active_call (GRPC::ActiveCall)


42
43
44
# File 'lib/gruf/lightstep/headers.rb', line 42

def initialize(active_call)
  @active_call = active_call
end

Instance Attribute Details

#active_callObject (readonly)

Returns the value of attribute active_call.



24
25
26
# File 'lib/gruf/lightstep/headers.rb', line 24

def active_call
  @active_call
end

Instance Method Details

#metadataHash

Returns:

  • (Hash)


64
65
66
# File 'lib/gruf/lightstep/headers.rb', line 64

def 
  @active_call.
end

#to_hHash

Returns:

  • (Hash)


71
72
73
# File 'lib/gruf/lightstep/headers.rb', line 71

def to_h
  @active_call.
end

#value(key) ⇒ String|NilClass

Return a B3 propagation header if present

Parameters:

  • key (Symbol)

Returns:

  • (String|NilClass)


52
53
54
55
56
57
58
59
# 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 [k] if .key?(k)
  end
  nil
end