Class: Periskop::Client::ExceptionWithContext
- Inherits:
-
Object
- Object
- Periskop::Client::ExceptionWithContext
- Defined in:
- lib/periskop/client/models.rb
Overview
ExceptionWithContext represents a reported exception with HTTP context
Constant Summary collapse
- NUM_HASH_CHARS =
8
- MAX_TRACES =
5
Instance Attribute Summary collapse
-
#exception_instance ⇒ Object
Returns the value of attribute exception_instance.
-
#http_context ⇒ Object
Returns the value of attribute http_context.
Instance Method Summary collapse
-
#aggregation_key ⇒ Object
Generates the aggregation key with a hash using the last MAX_TRACES.
- #as_json(_options = {}) ⇒ Object
-
#initialize(exception_instance, http_context, severity) ⇒ ExceptionWithContext
constructor
A new instance of ExceptionWithContext.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(exception_instance, http_context, severity) ⇒ ExceptionWithContext
Returns a new instance of ExceptionWithContext.
86 87 88 89 90 91 92 |
# File 'lib/periskop/client/models.rb', line 86 def initialize(exception_instance, http_context, severity) @exception_instance = exception_instance @http_context = http_context @severity = severity @uuid = SecureRandom.uuid @timestamp = Time.now.utc.iso8601 end |
Instance Attribute Details
#exception_instance ⇒ Object
Returns the value of attribute exception_instance.
81 82 83 |
# File 'lib/periskop/client/models.rb', line 81 def exception_instance @exception_instance end |
#http_context ⇒ Object
Returns the value of attribute http_context.
81 82 83 |
# File 'lib/periskop/client/models.rb', line 81 def http_context @http_context end |
Instance Method Details
#aggregation_key ⇒ Object
Generates the aggregation key with a hash using the last MAX_TRACES
95 96 97 98 99 |
# File 'lib/periskop/client/models.rb', line 95 def aggregation_key stacktrace_head = @exception_instance.stacktrace.first(MAX_TRACES).join('') error_hash = Digest::MD5.hexdigest(stacktrace_head)[0..NUM_HASH_CHARS - 1] "#{@exception_instance.class}@#{error_hash}" end |
#as_json(_options = {}) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/periskop/client/models.rb', line 101 def as_json( = {}) { error: @exception_instance, http_context: @http_context, severity: @severity, uuid: @uuid, timestamp: @timestamp } end |
#to_json(*options) ⇒ Object
111 112 113 |
# File 'lib/periskop/client/models.rb', line 111 def to_json(*) as_json(*).to_json(*) end |