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.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/harnex/runtime/session.rb', line 42 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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/harnex/runtime/session.rb', line 55 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
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/harnex/runtime/session.rb', line 72 def record_item(item) return unless item.is_a?(Hash) case item["type"] when "mcpToolCall", "dynamicToolCall", "fileChange", "webSearch" @counts[:tool_calls] += 1 when "commandExecution" @counts[:commands_executed] += 1 end end |
#snapshot ⇒ Object
83 84 85 |
# File 'lib/harnex/runtime/session.rb', line 83 def snapshot @counts.dup end |