Class: Periskop::Client::AggregatedException

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_errorsObject

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_countObject

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(_options = {})
  {
    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(*options)
  as_json(*options).to_json(*options)
end