Module: Bitfab::ReplayContext
- Defined in:
- lib/bitfab/replay.rb
Overview
Thread-local replay context management.
Class Method Summary collapse
- .current ⇒ Object
-
.with_context(test_run_id:, input_source_span_id: nil) ⇒ Object
Execute a block with replay context set on the current thread.
Class Method Details
.current ⇒ Object
11 12 13 |
# File 'lib/bitfab/replay.rb', line 11 def current Thread.current[REPLAY_CONTEXT_KEY] end |
.with_context(test_run_id:, input_source_span_id: nil) ⇒ Object
Execute a block with replay context set on the current thread. The context is automatically cleared when the block completes.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bitfab/replay.rb', line 17 def with_context(test_run_id:, input_source_span_id: nil) previous = Thread.current[REPLAY_CONTEXT_KEY] Thread.current[REPLAY_CONTEXT_KEY] = { test_run_id:, input_source_span_id: } yield ensure Thread.current[REPLAY_CONTEXT_KEY] = previous end |