Class: Periskop::Client::AggregatedException
- Inherits:
-
Object
- Object
- Periskop::Client::AggregatedException
- Defined in:
- lib/periskop/client/models.rb
Overview
AggregatedException represents the aggregation of a group of exceptions
Constant Summary collapse
- MAX_ERRORS =
10
Instance Attribute Summary collapse
-
#latest_errors ⇒ Object
Returns the value of attribute latest_errors.
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Instance Method Summary collapse
-
#add_exception(exception_with_context) ⇒ Object
Add exception to the list of latest errors up to MAX_ERRORS.
- #as_json(_options = {}) ⇒ Object
-
#initialize(aggregation_key, severity) ⇒ AggregatedException
constructor
A new instance of AggregatedException.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(aggregation_key, severity) ⇒ AggregatedException
Returns a new instance of AggregatedException.
130 131 132 133 134 135 136 |
# File 'lib/periskop/client/models.rb', line 130 def initialize(aggregation_key, severity) @aggregation_key = aggregation_key @latest_errors = [] @total_count = 0 @severity = severity @created_at = Time.now.utc.iso8601 end |
Instance Attribute Details
#latest_errors ⇒ Object
Returns the value of attribute latest_errors.
126 127 128 |
# File 'lib/periskop/client/models.rb', line 126 def latest_errors @latest_errors end |
#total_count ⇒ Object
Returns the value of attribute total_count.
126 127 128 |
# File 'lib/periskop/client/models.rb', line 126 def total_count @total_count end |
Instance Method Details
#add_exception(exception_with_context) ⇒ Object
Add exception to the list of latest errors up to MAX_ERRORS
139 140 141 142 143 144 145 |
# File 'lib/periskop/client/models.rb', line 139 def add_exception(exception_with_context) if @latest_errors.size >= MAX_ERRORS @latest_errors.shift end @latest_errors.push(exception_with_context) @total_count += 1 end |
#as_json(_options = {}) ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/periskop/client/models.rb', line 147 def as_json( = {}) { aggregation_key: @aggregation_key, created_at: @created_at, total_count: @total_count, severity: @severity, latest_errors: @latest_errors } end |
#to_json(*options) ⇒ Object
157 158 159 |
# File 'lib/periskop/client/models.rb', line 157 def to_json(*) as_json(*).to_json(*) end |