Class: Harnex::Session::EventCounters
- Inherits:
-
Object
- Object
- Harnex::Session::EventCounters
- Defined in:
- lib/harnex/runtime/session.rb
Instance Method Summary collapse
-
#initialize ⇒ EventCounters
constructor
A new instance of EventCounters.
- #record(type) ⇒ Object
- #record_item(item) ⇒ Object
- #snapshot ⇒ Object
Constructor Details
#initialize ⇒ EventCounters
Returns a new instance of EventCounters.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/harnex/runtime/session.rb', line 39 def initialize @counts = { stalls: 0, force_resumes: 0, disconnections: 0, compactions: 0, retries: 0, throttle_429: 0, tool_calls: 0, commands_executed: 0 } end |
Instance Method Details
#record(type) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/harnex/runtime/session.rb', line 52 def record(type) case type.to_s when "log_idle" @counts[:stalls] += 1 when "resume" @counts[:force_resumes] += 1 when "disconnect", "disconnection", "disconnected" @counts[:disconnections] += 1 when "compaction" @counts[:compactions] += 1 when "attempt_retry_scheduled" @counts[:retries] += 1 when "throttle_429" @counts[:throttle_429] += 1 end end |
#record_item(item) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/harnex/runtime/session.rb', line 69 def record_item(item) return unless item.is_a?(Hash) case item["type"] when "mcpToolCall", "dynamicToolCall" @counts[:tool_calls] += 1 when "commandExecution" @counts[:commands_executed] += 1 end end |
#snapshot ⇒ Object
80 81 82 |
# File 'lib/harnex/runtime/session.rb', line 80 def snapshot @counts.dup end |