Class: Hermes::TraceContext
- Inherits:
-
Object
- Object
- Hermes::TraceContext
- Defined in:
- lib/hermes/trace_context.rb
Instance Method Summary collapse
-
#initialize(origin_event_headers = {}) ⇒ TraceContext
constructor
A new instance of TraceContext.
- #parent_span ⇒ Object
- #service ⇒ Object
- #span ⇒ Object
- #trace ⇒ Object
Constructor Details
#initialize(origin_event_headers = {}) ⇒ TraceContext
Returns a new instance of TraceContext.
10 11 12 |
# File 'lib/hermes/trace_context.rb', line 10 def initialize(origin_event_headers = {}) @origin_event_headers = origin_event_headers.to_h end |
Instance Method Details
#parent_span ⇒ Object
22 23 24 |
# File 'lib/hermes/trace_context.rb', line 22 def parent_span origin_event_headers.fetch(Hermes::B3PropagationModelHeaders.span_id_key, nil) end |
#service ⇒ Object
26 27 28 |
# File 'lib/hermes/trace_context.rb', line 26 def service Hermes.configuration.application_prefix or raise "missing application prefix!" end |
#span ⇒ Object
18 19 20 |
# File 'lib/hermes/trace_context.rb', line 18 def span @span ||= [trace[0..last_trace_index_for_span], DELIMITER, service_seed_for_span, DELIMITER, uuid].join end |
#trace ⇒ Object
14 15 16 |
# File 'lib/hermes/trace_context.rb', line 14 def trace @trace ||= origin_event_headers.fetch(Hermes::B3PropagationModelHeaders.trace_id_key, SecureRandom.hex(32)) end |