Class: RailsSpotlight::Event
- Inherits:
-
ActiveSupport::Notifications::Event
- Object
- ActiveSupport::Notifications::Event
- RailsSpotlight::Event
- Defined in:
- lib/rails_spotlight/event.rb
Overview
Subclass of ActiveSupport Event that is JSON encodable
Constant Summary collapse
- NOT_JSON_ENCODABLE =
'Not JSON Encodable'
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, start, ending, transaction_id, payload) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(name, start, ending, transaction_id, payload) ⇒ Event
Returns a new instance of Event.
15 16 17 18 |
# File 'lib/rails_spotlight/event.rb', line 15 def initialize(name, start, ending, transaction_id, payload) super(name, start, ending, transaction_id, json_encodable(payload)) @duration = 1000.0 * (ending - start) end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
13 14 15 |
# File 'lib/rails_spotlight/event.rb', line 13 def duration @duration end |
Class Method Details
.events_for_exception(exception_wrapper) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_spotlight/event.rb', line 20 def self.events_for_exception(exception_wrapper) if defined?(ActionDispatch::ExceptionWrapper) exception = exception_wrapper.exception trace = exception_wrapper.application_trace trace = exception_wrapper.framework_trace if trace.empty? else exception = exception_wrapper trace = exception.backtrace end trace.unshift "#{exception.class} (#{exception.})" trace.map do |call| Event.new('process_action.action_controller.exception', 0, 0, nil, call: call) end end |