Class: Stoplight::Domain::MetricsSnapshot Private
- Inherits:
-
Data
- Object
- Data
- Stoplight::Domain::MetricsSnapshot
- Defined in:
- lib/stoplight/domain/metrics_snapshot.rb,
lib/stoplight/domain/metrics_snapshot.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Request metrics over a given window.
Instance Attribute Summary collapse
-
#consecutive_errors ⇒ Object
readonly
Returns the value of attribute consecutive_errors.
-
#consecutive_successes ⇒ Object
readonly
Returns the value of attribute consecutive_successes.
-
#errors ⇒ Object
A number of errors withing requested window.
-
#last_error ⇒ Object
readonly
Returns the value of attribute last_error.
-
#last_success_at ⇒ Object
readonly
Returns the value of attribute last_success_at.
-
#successes ⇒ Object
A number of successes withing requested window.
Instance Method Summary collapse
-
#error_rate ⇒ Float
private
Calculates the error rate based on the number of successes and errors.
- #errors! ⇒ Object private
- #last_error_at ⇒ Time? private
- #requests ⇒ Integer private
- #successes! ⇒ Object private
Instance Attribute Details
#consecutive_errors ⇒ Object (readonly)
Returns the value of attribute consecutive_errors
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def consecutive_errors @consecutive_errors end |
#consecutive_successes ⇒ Object (readonly)
Returns the value of attribute consecutive_successes
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def consecutive_successes @consecutive_successes end |
#errors ⇒ Object
A number of errors withing requested window. Zero for non-windowed metrics
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def errors @errors end |
#last_error ⇒ Object (readonly)
Returns the value of attribute last_error
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def last_error @last_error end |
#last_success_at ⇒ Object (readonly)
Returns the value of attribute last_success_at
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def last_success_at @last_success_at end |
#successes ⇒ Object
A number of successes withing requested window. Zero for non-windowed metrics
8 9 10 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 8 def successes @successes end |
Instance Method Details
#error_rate ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates the error rate based on the number of successes and errors.
27 28 29 30 31 32 33 34 35 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 27 def error_rate return unless requests # we effectively check if this is windowed metrics if (successes! + errors!).zero? 0.0 else errors!.fdiv(successes! + errors!) end end |
#errors! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 53 def errors! errors or raise TypeError, "errors must not be nil" end |
#last_error_at ⇒ Time?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 45 def last_error_at last_error&.time end |
#requests ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 38 def requests if successes && errors # we effectively check if this is windowed metrics successes! + errors! end end |
#successes! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 49 def successes! successes or raise TypeError, "success must not be nil" end |