Class: Radar::ExceptionEvent
- Inherits:
-
Object
- Object
- Radar::ExceptionEvent
- Defined in:
- lib/radar/exception_event.rb
Overview
Represents the event of an exception being captured. This class contains references to the Application and exception which is raised.
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#occurred_at ⇒ Object
readonly
Returns the value of attribute occurred_at.
Instance Method Summary collapse
-
#initialize(application, exception, extra = nil) ⇒ ExceptionEvent
constructor
A new instance of ExceptionEvent.
-
#to_hash ⇒ Hash
A hash of information about this exception event.
-
#to_json ⇒ String
JSONified #to_hash output.
-
#uniqueness_hash ⇒ String
Returns uniqueness hash to test if one event is roughly equivalent to another.
Constructor Details
#initialize(application, exception, extra = nil) ⇒ ExceptionEvent
Returns a new instance of ExceptionEvent.
14 15 16 17 18 19 |
# File 'lib/radar/exception_event.rb', line 14 def initialize(application, exception, extra=nil) @application = application @exception = exception @extra = extra || {} @occurred_at = Time.now end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
9 10 11 |
# File 'lib/radar/exception_event.rb', line 9 def application @application end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
10 11 12 |
# File 'lib/radar/exception_event.rb', line 10 def exception @exception end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
12 13 14 |
# File 'lib/radar/exception_event.rb', line 12 def extra @extra end |
#occurred_at ⇒ Object (readonly)
Returns the value of attribute occurred_at.
11 12 13 |
# File 'lib/radar/exception_event.rb', line 11 def occurred_at @occurred_at end |
Instance Method Details
#to_hash ⇒ Hash
A hash of information about this exception event. This includes Application#to_hash as well as information about the exception. This also includes any data_extensions if specified.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/radar/exception_event.rb', line 27 def to_hash result = { :application => application.to_hash, :exception => { :klass => exception.class.to_s, :message => exception., :backtrace => exception.backtrace, :uniqueness_hash => uniqueness_hash }, :occurred_at => occurred_at.to_i } if !application.config.data_extensions.empty? application.config.data_extensions.values.each do |extension| Support::Hash.deep_merge!(result, extension.new(self).to_hash) end end result end |
#to_json ⇒ String
JSONified #to_hash output.
50 51 52 |
# File 'lib/radar/exception_event.rb', line 50 def to_json to_hash.to_json end |
#uniqueness_hash ⇒ String
Returns uniqueness hash to test if one event is roughly equivalent to another. The uniqueness hash is generated by taking the exception backtrace and class and generating the SHA1 hash of those concatenated.
59 60 61 |
# File 'lib/radar/exception_event.rb', line 59 def uniqueness_hash Digest::SHA1.hexdigest("#{exception.class}-#{exception.backtrace rescue 'blank'}") end |