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.



103
104
105
106
107
108
109
# File 'lib/periskop/client/models.rb', line 103

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.



99
100
101
# File 'lib/periskop/client/models.rb', line 99

def latest_errors
  @latest_errors
end

#total_countObject

Returns the value of attribute total_count.



99
100
101
# File 'lib/periskop/client/models.rb', line 99

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



112
113
114
115
116
117
118
# File 'lib/periskop/client/models.rb', line 112

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



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

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



130
131
132
# File 'lib/periskop/client/models.rb', line 130

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