Class: AgentHarness::Orchestration::ProviderHealthMetrics
- Inherits:
-
Object
- Object
- AgentHarness::Orchestration::ProviderHealthMetrics
- Defined in:
- lib/agent_harness/orchestration/health_monitor.rb
Overview
Internal class for tracking per-provider metrics
Instance Attribute Summary collapse
-
#recent_failures ⇒ Object
readonly
Returns the value of attribute recent_failures.
-
#recent_successes ⇒ Object
readonly
Returns the value of attribute recent_successes.
-
#total_calls ⇒ Object
readonly
Returns the value of attribute total_calls.
Instance Method Summary collapse
-
#initialize(window_size) ⇒ ProviderHealthMetrics
constructor
A new instance of ProviderHealthMetrics.
- #record_failure ⇒ Object
- #record_success ⇒ Object
- #success_rate ⇒ Object
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_failures ⇒ Object (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_successes ⇒ Object (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_calls ⇒ Object (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_failure ⇒ Object
136 137 138 |
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 136 def record_failure add_event(:failure) end |
#record_success ⇒ Object
132 133 134 |
# File 'lib/agent_harness/orchestration/health_monitor.rb', line 132 def record_success add_event(:success) end |
#success_rate ⇒ Object
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 |