Module: Tremolo::ExceptionTracking
- Defined in:
- lib/tremolo/exception_tracking.rb
Class Method Summary collapse
Instance Method Summary collapse
- #backtrace_location(exception) ⇒ Object
- #backtrace_tags(exception) ⇒ Object
- #track_exception_with_tremolo(exception) ⇒ Object
- #track_exception_with_tremolo_and_raise(exception) ⇒ Object
Class Method Details
.included(controller) ⇒ Object
4 5 6 7 |
# File 'lib/tremolo/exception_tracking.rb', line 4 def self.included(controller) controller.rescue_from ::Exception, with: :track_exception_with_tremolo_and_raise end |
Instance Method Details
#backtrace_location(exception) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tremolo/exception_tracking.rb', line 19 def backtrace_location(exception) if exception.respond_to?(:backtrace_locations) if location = (exception.backtrace_locations || []).first { path: location.path, line: location.lineno } else {} end else {} end end |
#backtrace_tags(exception) ⇒ Object
13 14 15 16 17 |
# File 'lib/tremolo/exception_tracking.rb', line 13 def (exception) { name: exception.class.name }.merge!(backtrace_location(exception)) end |
#track_exception_with_tremolo(exception) ⇒ Object
9 10 11 |
# File 'lib/tremolo/exception_tracking.rb', line 9 def track_exception_with_tremolo(exception) tracker.increment('exception', (exception)) end |
#track_exception_with_tremolo_and_raise(exception) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/tremolo/exception_tracking.rb', line 35 def track_exception_with_tremolo_and_raise(exception) track_exception_with_tremolo(exception) # re-raise the exception as normal raise exception end |