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.



122
123
124
125
126
127
128
# File 'lib/periskop/client/models.rb', line 122

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.



118
119
120
# File 'lib/periskop/client/models.rb', line 118

def latest_errors
  @latest_errors
end

#total_countObject

Returns the value of attribute total_count.



118
119
120
# File 'lib/periskop/client/models.rb', line 118

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



131
132
133
134
135
136
137
# File 'lib/periskop/client/models.rb', line 131

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



139
140
141
142
143
144
145
146
147
# File 'lib/periskop/client/models.rb', line 139

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



149
150
151
# File 'lib/periskop/client/models.rb', line 149

def to_json(*options)
  as_json(*options).to_json(*options)
end