Class: Freddy::TraceCarrier
- Inherits:
-
Object
- Object
- Freddy::TraceCarrier
- Defined in:
- lib/freddy/trace_carrier.rb
Overview
Carrier for rabbitmq following OpenTracing API See github.com/opentracing/opentracing-ruby/blob/master/lib/opentracing/carrier.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(properties) ⇒ TraceCarrier
constructor
A new instance of TraceCarrier.
Constructor Details
#initialize(properties) ⇒ TraceCarrier
Returns a new instance of TraceCarrier.
5 6 7 |
# File 'lib/freddy/trace_carrier.rb', line 5 def initialize(properties) @properties = properties end |
Instance Method Details
#[](key) ⇒ Object
9 10 11 |
# File 'lib/freddy/trace_carrier.rb', line 9 def [](key) @properties.headers && @properties.headers["x-trace-#{key}"] end |
#[]=(key, value) ⇒ Object
13 14 15 16 |
# File 'lib/freddy/trace_carrier.rb', line 13 def []=(key, value) @properties[:headers] ||= {} @properties[:headers]["x-trace-#{key}"] = value end |
#each(&block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/freddy/trace_carrier.rb', line 18 def each(&block) Hash[ (@properties.headers || {}) .select {|key, _| key =~ /^x-trace/} .map {|key, value| [key.sub(/x-trace-/, ''), value]} ].each(&block) end |