Module: EventHub::CorrelationId
- Defined in:
- lib/eventhub/correlation_id.rb
Overview
Manages correlation_id for distributed tracing Storage mechanism can be swapped if needed (e.g., Thread.current -> Fiber storage)
Class Method Summary collapse
- .clear ⇒ Object
- .current ⇒ Object
- .current=(value) ⇒ Object
-
.with(correlation_id) ⇒ Object
Execute block with correlation_id set, ensures cleanup.
Class Method Details
.clear ⇒ Object
15 16 17 |
# File 'lib/eventhub/correlation_id.rb', line 15 def clear Thread.current[:eventhub_correlation_id] = nil end |
.current ⇒ Object
7 8 9 |
# File 'lib/eventhub/correlation_id.rb', line 7 def current Thread.current[:eventhub_correlation_id] end |
.current=(value) ⇒ Object
11 12 13 |
# File 'lib/eventhub/correlation_id.rb', line 11 def current=(value) Thread.current[:eventhub_correlation_id] = value end |
.with(correlation_id) ⇒ Object
Execute block with correlation_id set, ensures cleanup
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/eventhub/correlation_id.rb', line 20 def with(correlation_id) if correlation_id.nil? || correlation_id.to_s.empty? yield else old_value = current begin self.current = correlation_id yield ensure self.current = old_value end end end |