Class: AgentHarness::Orchestration::ProviderHealthMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_harness/orchestration/health_monitor.rb

Overview

Internal class for tracking per-provider metrics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window_size) ⇒ ProviderHealthMetrics

Returns a new instance of ProviderHealthMetrics.



124
125
126
127
128
129
130
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 124

def initialize(window_size)
  @window_size = window_size
  @events = []
  @total_calls = 0
  @recent_successes = 0
  @recent_failures = 0
end

Instance Attribute Details

#recent_failuresObject (readonly)

Returns the value of attribute recent_failures.



122
123
124
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 122

def recent_failures
  @recent_failures
end

#recent_successesObject (readonly)

Returns the value of attribute recent_successes.



122
123
124
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 122

def recent_successes
  @recent_successes
end

#total_callsObject (readonly)

Returns the value of attribute total_calls.



122
123
124
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 122

def total_calls
  @total_calls
end

Instance Method Details

#record_failureObject



136
137
138
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 136

def record_failure
  add_event(:failure)
end

#record_successObject



132
133
134
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 132

def record_success
  add_event(:success)
end

#success_rateObject



140
141
142
143
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 140

def success_rate
  return 1.0 if @events.empty?
  @recent_successes.to_f / @events.size
end