class Periskop::Client::ExceptionCollector
ExceptionCollector
collects reported exceptions and aggregates them
Attributes
aggregated_exceptions_dict[R]
Public Class Methods
new()
click to toggle source
# File lib/periskop/client/collector.rb, line 9 def initialize @aggregated_exceptions_dict = {} @uuid = SecureRandom.uuid end
Public Instance Methods
aggregated_exceptions()
click to toggle source
# File lib/periskop/client/collector.rb, line 16 def aggregated_exceptions Payload.new(@aggregated_exceptions_dict.values, @uuid) end
report(exception)
click to toggle source
Report an exception Params:
- exception
-
captured exception
# File lib/periskop/client/collector.rb, line 23 def report(exception) add_exception(exception, nil) end
report_with_context(exception, context)
click to toggle source
Report an exception with context Params:
- exception
-
captured exception
- context
-
HTTP context of the exception
# File lib/periskop/client/collector.rb, line 31 def report_with_context(exception, context) add_exception(exception, context) end
Private Instance Methods
add_exception(exception, context)
click to toggle source
# File lib/periskop/client/collector.rb, line 37 def add_exception(exception, context) exception_instance = ExceptionInstance.from_exception(exception) exception_with_context = ExceptionWithContext.new( exception_instance, context, Periskop::Client::SEVERITY_ERROR ) aggregation_key = exception_with_context.aggregation_key() unless @aggregated_exceptions_dict.key?(aggregation_key) aggregated_exception = AggregatedException.new( aggregation_key, Periskop::Client::SEVERITY_ERROR ) @aggregated_exceptions_dict.store(aggregation_key, aggregated_exception) end aggregated_exception = @aggregated_exceptions_dict[aggregation_key] aggregated_exception.add_exception(exception_with_context) end