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,
sig/_private/stoplight/domain/metrics_snapshot.rbs
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
private
Returns the value of attribute consecutive_errors.
-
#consecutive_successes ⇒ Object
readonly
private
Returns the value of attribute consecutive_successes.
-
#errors ⇒ Integer?
private
A number of errors withing requested window.
-
#last_error ⇒ Object
readonly
private
Returns the value of attribute last_error.
-
#last_success_at ⇒ Object
readonly
private
Returns the value of attribute last_success_at.
-
#successes ⇒ Integer?
private
A number of successes withing requested window.
Class Method Summary collapse
- .new ⇒ Object private
Instance Method Summary collapse
-
#error_rate ⇒ Float
private
Calculates the error rate based on the number of successes and errors.
- #errors! ⇒ Integer private
- #initialize ⇒ Object constructor private
- #last_error_at ⇒ Time? private
- #requests ⇒ Integer private
- #successes! ⇒ Integer private
Constructor Details
#initialize ⇒ 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.
20 |
# File 'sig/_private/stoplight/domain/metrics_snapshot.rbs', line 20
def initialize: (
|
Instance Attribute Details
#consecutive_errors ⇒ Object (readonly)
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.
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)
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.
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 ⇒ 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.
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)
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.
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)
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.
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 ⇒ 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.
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 |
Class Method Details
.new ⇒ 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.
11 |
# File 'sig/_private/stoplight/domain/metrics_snapshot.rbs', line 11
def self.new: (
|
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! ⇒ 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.
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! ⇒ 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.
49 50 51 |
# File 'lib/stoplight/domain/metrics_snapshot.rb', line 49 def successes! successes or raise TypeError, "success must not be nil" end |