Class: Ibex::Runtime::EventJSONLTracer
- Inherits:
-
Object
- Object
- Ibex::Runtime::EventJSONLTracer
- Defined in:
- lib/ibex/runtime/event_jsonl_tracer.rb
Overview
Emits schema-v1 immutable runtime events as JSON Lines.
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
@rbs! interface _EventTraceOutput def puts: (String) -> untyped end.
-
#subscription ⇒ Object
readonly
: Observation::Subscription.
Class Method Summary collapse
Instance Method Summary collapse
- #detach ⇒ Object
-
#initialize(parser, output) ⇒ EventJSONLTracer
constructor
A new instance of EventJSONLTracer.
Constructor Details
#initialize(parser, output) ⇒ EventJSONLTracer
Returns a new instance of EventJSONLTracer.
20 21 22 23 24 |
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 20 def initialize(parser, output) @parser = parser @output = output @subscription = parser.observe { |event| output.puts(JSON.generate(event.to_h)) } end |
Instance Attribute Details
#parser ⇒ Object (readonly)
@rbs! interface _EventTraceOutput def puts: (String) -> untyped end
16 17 18 |
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 16 def parser @parser end |
#subscription ⇒ Object (readonly)
: Observation::Subscription
17 18 19 |
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 17 def subscription @subscription end |
Class Method Details
.attach(parser, io:) ⇒ Object
32 33 34 |
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 32 def self.attach(parser, io:) new(parser, io) end |
Instance Method Details
#detach ⇒ Object
27 28 29 |
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 27 def detach @parser.unobserve(@subscription) end |