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.
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#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.
15 16 17 18 19 20 21 |
# File 'lib/radar/exception_event.rb', line 15 def initialize(application, exception, extra=nil) @application = application @exception = exception @backtrace = Backtrace.new(exception.backtrace) @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 |
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
11 12 13 |
# File 'lib/radar/exception_event.rb', line 11 def backtrace @backtrace 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.
13 14 15 |
# File 'lib/radar/exception_event.rb', line 13 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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/radar/exception_event.rb', line 29 def to_hash return @_to_hash_result if @_to_hash_result result = { :application => application.to_hash, :exception => { :klass => exception.class.to_s, :message => exception., :backtrace => backtrace, :uniqueness_hash => uniqueness_hash }, :occurred_at => occurred_at.to_i } application.config.data_extensions.values.each do |extension| Support::Hash.deep_merge!(result, extension.new(self).to_hash || {}) end application.config.filters.values.each do |filter| result = filter.call(result) end # Cache the resulting hash to it is only generated once. @_to_hash_result = result result end |
#to_json ⇒ String
JSONified #to_hash output.
58 59 60 |
# File 'lib/radar/exception_event.rb', line 58 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.
67 68 69 |
# File 'lib/radar/exception_event.rb', line 67 def uniqueness_hash Digest::SHA1.hexdigest("#{exception.class}-#{exception.backtrace rescue 'blank'}") end |