Class: Ibex::Runtime::EventJSONLTracer

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

Overview

Emits schema-v1 immutable runtime events as JSON Lines.

Defined Under Namespace

Modules: _EventTraceOutput

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser, output) ⇒ EventJSONLTracer

Returns a new instance of EventJSONLTracer.

RBS:

  • (Parser parser, _EventTraceOutput output) -> void

Parameters:



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

#parserParser (readonly)

RBS:

  • interface _EventTraceOutput
      def puts: (String) -> untyped
    end

Returns:



16
17
18
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 16

def parser
  @parser
end

#subscriptionObservation::Subscription (readonly)

Signature:

  • Observation::Subscription

Returns:



17
18
19
# File 'lib/ibex/runtime/event_jsonl_tracer.rb', line 17

def subscription
  @subscription
end

Class Method Details

.attach(parser, io:) ⇒ void

This method returns an undefined value.

RBS:

  • [P < Parser] (P parser, io: _EventTraceOutput) -> EventJSONLTracer



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

#detachBoolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


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

def detach
  @parser.unobserve(@subscription)
end