Module: Bitfab::TraceState
- Defined in:
- lib/bitfab/span_context.rb
Overview
Global storage for trace states (trace_id -> state hash)
Class Method Summary collapse
- .clear_all ⇒ Object
- .create(trace_id, test_run_id: nil, input_source_trace_id: nil) ⇒ Object
- .delete(trace_id) ⇒ Object
- .get(trace_id) ⇒ Object
Class Method Details
.clear_all ⇒ Object
157 158 159 |
# File 'lib/bitfab/span_context.rb', line 157 def clear_all @states_mutex.synchronize { @states.clear } end |
.create(trace_id, test_run_id: nil, input_source_trace_id: nil) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/bitfab/span_context.rb', line 134 def create(trace_id, test_run_id: nil, input_source_trace_id: nil) @states_mutex.synchronize do @states[trace_id] ||= begin started_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ") { trace_id:, started_at:, test_run_id:, input_source_trace_id:, # Capture the wall clock now, before the wrapped function runs. # Stored on every trace (no IO, harmless) so any trace can later be # replayed against a historical branch; the provider is resolved at # replay time. db_snapshot_ref: DbSnapshot.build_snapshot_ref(started_at) }.compact end end end |
.delete(trace_id) ⇒ Object
153 154 155 |
# File 'lib/bitfab/span_context.rb', line 153 def delete(trace_id) @states_mutex.synchronize { @states.delete(trace_id) } end |
.get(trace_id) ⇒ Object
130 131 132 |
# File 'lib/bitfab/span_context.rb', line 130 def get(trace_id) @states_mutex.synchronize { @states[trace_id] } end |