Class: Gruf::Zipkin::Headers
- Inherits:
-
Object
- Object
- Gruf::Zipkin::Headers
- Defined in:
- lib/gruf/zipkin/headers.rb
Overview
Abstraction accessor class for B3 propagation headers across GRPC ActiveCall objects
Constant Summary collapse
- ZIPKIN_KEYS =
{ parent_span_id: %w(x-b3-parentspanid X-B3-ParentSpanId HTTP_X_B3_PARENTSPANID), span_id: %w(x-b3-spanid X-B3-SpanId HTTP_X_B3_SPANID), trace_id: %w(x-b3-traceid X-B3-TraceId HTTP_X_B3_TRACEID), sampled: %w(x-b3-sampled X-B3-Sampled HTTP_X_B3_SAMPLED), flags: %w(x-b3-flags X-B3-Flags HTTP_X_B3_FLAGS) }.freeze
Instance Attribute Summary collapse
-
#active_call ⇒ Object
readonly
Returns the value of attribute active_call.
Instance Method Summary collapse
-
#initialize(active_call) ⇒ Headers
constructor
A new instance of Headers.
-
#value(key) ⇒ String|NilClass
Return a B3 propagation header if present.
Constructor Details
#initialize(active_call) ⇒ Headers
Returns a new instance of Headers.
38 39 40 |
# File 'lib/gruf/zipkin/headers.rb', line 38 def initialize(active_call) @active_call = active_call end |
Instance Attribute Details
#active_call ⇒ Object (readonly)
Returns the value of attribute active_call.
22 23 24 |
# File 'lib/gruf/zipkin/headers.rb', line 22 def active_call @active_call end |
Instance Method Details
#value(key) ⇒ String|NilClass
Return a B3 propagation header if present
48 49 50 51 52 53 54 |
# File 'lib/gruf/zipkin/headers.rb', line 48 def value(key) return nil unless ZIPKIN_KEYS.key?(key) ZIPKIN_KEYS[key].each do |k| return @active_call.[k] if @active_call..key?(k) end nil end |