Class: Ibex::Runtime::EventJSONLTracer

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/event_jsonl_tracer.rb

Overview

Emits schema-v1 immutable runtime events as JSON Lines.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#parserObject (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

#subscriptionObject (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

#detachObject



27
28
29
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 27

def detach
  @parser.unobserve(@subscription)
end