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.
67 68 69 70 71 72 73 |
# File 'lib/periskop/client/models.rb', line 67 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.
62 63 64 |
# File 'lib/periskop/client/models.rb', line 62 def exception_instance @exception_instance end |
#http_context ⇒ Object
Returns the value of attribute http_context.
62 63 64 |
# File 'lib/periskop/client/models.rb', line 62 def http_context @http_context end |
Instance Method Details
#aggregation_key ⇒ Object
Generates the aggregation key with a hash using the last MAX_TRACES
76 77 78 79 80 |
# File 'lib/periskop/client/models.rb', line 76 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
82 83 84 85 86 87 88 89 90 |
# File 'lib/periskop/client/models.rb', line 82 def as_json( = {}) { error: @exception_instance, http_context: @http_context, severity: @severity, uuid: @uuid, timestamp: @timestamp } end |
#to_json(*options) ⇒ Object
92 93 94 |
# File 'lib/periskop/client/models.rb', line 92 def to_json(*) as_json(*).to_json(*) end |