Module: Philiprehberger::Circuit::Metrics
- Included in:
- Breaker
- Defined in:
- lib/philiprehberger/circuit/metrics.rb
Overview
Thread-safe counters and state change log for monitoring
Instance Method Summary collapse
-
#last_failure ⇒ Hash?
Most recent failure recorded by the breaker, or nil when none has occurred since the last reset.
- #metrics ⇒ Object
-
#metrics_reset! ⇒ Object
Zero counters and clear the state-change log without altering the circuit’s current state or transition timestamps.
Instance Method Details
#last_failure ⇒ Hash?
Most recent failure recorded by the breaker, or nil when none has occurred since the last reset.
15 16 17 |
# File 'lib/philiprehberger/circuit/metrics.rb', line 15 def last_failure @mutex.synchronize { @last_failure&.dup } end |
#metrics ⇒ Object
7 8 9 |
# File 'lib/philiprehberger/circuit/metrics.rb', line 7 def metrics @mutex.synchronize { metrics_snapshot } end |
#metrics_reset! ⇒ Object
Zero counters and clear the state-change log without altering the circuit’s current state or transition timestamps. Also clears the last_failure record.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/philiprehberger/circuit/metrics.rb', line 22 def metrics_reset! @mutex.synchronize do @success_count = 0 @metrics_failure_count = 0 @rejected_count = 0 @state_changes = [] @last_failure = nil end self end |