Module: Upkeep::Runtime::Observation
- Defined in:
- lib/upkeep/runtime.rb
Constant Summary collapse
- THREAD_KEY =
:upkeep_recorder
Class Method Summary collapse
- .capture_frame(frame_id, metadata = {}) ⇒ Object
- .capture_request(profile: false) ⇒ Object
- .record_ambient_replay_input(source, key, value) ⇒ Object
- .record_dependency(dependency) ⇒ Object
- .record_relation_provenance(collection, model_name:, analysis:) ⇒ Object
- .recorder ⇒ Object
- .recording? ⇒ Boolean
- .refuse_boundary(boundary) ⇒ Object
- .relation_provenance_for(collection) ⇒ Object
Class Method Details
.capture_frame(frame_id, metadata = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/upkeep/runtime.rb', line 28 def capture_frame(frame_id, = {}) recorder = Thread.current[THREAD_KEY] return yield unless recorder recorder.with_frame(frame_id, ) { yield } end |
.capture_request(profile: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/upkeep/runtime.rb', line 16 def capture_request(profile: false) previous = Thread.current[THREAD_KEY] recorder = Recorder.new(profile: profile) Thread.current[THREAD_KEY] = recorder result = yield(recorder) recorder.flush_pending_dependencies [result, recorder] ensure Thread.current[THREAD_KEY] = previous end |
.record_ambient_replay_input(source, key, value) ⇒ Object
39 40 41 |
# File 'lib/upkeep/runtime.rb', line 39 def record_ambient_replay_input(source, key, value) Thread.current[THREAD_KEY]&.record_ambient_replay_input(source, key, value) end |
.record_dependency(dependency) ⇒ Object
35 36 37 |
# File 'lib/upkeep/runtime.rb', line 35 def record_dependency(dependency) Thread.current[THREAD_KEY]&.record_dependency(dependency) end |
.record_relation_provenance(collection, model_name:, analysis:) ⇒ Object
43 44 45 |
# File 'lib/upkeep/runtime.rb', line 43 def record_relation_provenance(collection, model_name:, analysis:) Thread.current[THREAD_KEY]&.record_relation_provenance(collection, model_name: model_name, analysis: analysis) end |
.recorder ⇒ Object
55 56 57 |
# File 'lib/upkeep/runtime.rb', line 55 def recorder Thread.current[THREAD_KEY] end |
.recording? ⇒ Boolean
59 60 61 |
# File 'lib/upkeep/runtime.rb', line 59 def recording? !!Thread.current[THREAD_KEY] end |
.refuse_boundary(boundary) ⇒ Object
51 52 53 |
# File 'lib/upkeep/runtime.rb', line 51 def refuse_boundary(boundary) Thread.current[THREAD_KEY]&.refuse_boundary(**boundary) end |
.relation_provenance_for(collection) ⇒ Object
47 48 49 |
# File 'lib/upkeep/runtime.rb', line 47 def relation_provenance_for(collection) Thread.current[THREAD_KEY]&.relation_provenance_for(collection) end |