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
194 195 196 |
# File 'lib/bitfab/span_context.rb', line 194 def clear_all @states_mutex.synchronize { @states.clear } end |
.create(trace_id, test_run_id: nil, input_source_trace_id: nil) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/bitfab/span_context.rb', line 171 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
190 191 192 |
# File 'lib/bitfab/span_context.rb', line 190 def delete(trace_id) @states_mutex.synchronize { @states.delete(trace_id) } end |
.get(trace_id) ⇒ Object
167 168 169 |
# File 'lib/bitfab/span_context.rb', line 167 def get(trace_id) @states_mutex.synchronize { @states[trace_id] } end |