Class: OneApm::NoticedError
- Inherits:
-
Object
- Object
- OneApm::NoticedError
- Extended by:
- CollectionHelper
- Includes:
- Coerce
- Defined in:
- lib/one_apm/errors/noticed_error.rb
Overview
This class encapsulates an error that was noticed by OneApm in a managed app.
Constant Summary collapse
- OA_STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE =
"Message removed by OneApm 'strip_exception_messages' setting"
Constants included from CollectionHelper
CollectionHelper::OA_DEFAULT_ARRAY_TRUNCATION_SIZE, CollectionHelper::OA_DEFAULT_TRUNCATION_SIZE
Instance Attribute Summary collapse
-
#exception_class_name ⇒ Object
Returns the value of attribute exception_class_name.
-
#exception_id ⇒ Object
readonly
Returns the value of attribute exception_id.
-
#is_internal ⇒ Object
readonly
Returns the value of attribute is_internal.
-
#message ⇒ Object
Returns the value of attribute message.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(path, data, exception, timestamp = Time.now) ⇒ NoticedError
constructor
A new instance of NoticedError.
- #to_collector_array(encoder = nil) ⇒ Object
Methods included from CollectionHelper
normalize_params, strip_oa_from_backtrace
Methods included from Coerce
#event_params, #float, #int, #int_or_nil, #log_failure, #string
Constructor Details
#initialize(path, data, exception, timestamp = Time.now) ⇒ NoticedError
Returns a new instance of NoticedError.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 54 55 56 |
# File 'lib/one_apm/errors/noticed_error.rb', line 15 def initialize(path, data, exception, = Time.now) @exception_id = exception.object_id @path = path @params = OneApm::NoticedError.normalize_params(data) @exception_class_name = exception.is_a?(Exception) ? exception.class.name : 'Error' # It's critical that we not hold onto the exception class constant in this # class. These objects get serialized for Resque to a process that might # not have the original exception class loaded, so do all processing now # while we have the actual exception! @is_internal = (exception.class < OneApm::Agent::InternalAgentError) if exception.nil? @message = '<no message>' elsif exception.respond_to?('original_exception') @message = (exception.original_exception || exception).to_s else # exception is not nil, but does not respond to original_exception @message = exception.to_s end unless @message.is_a?(String) # In pre-1.9.3, Exception.new({}).to_s.class != String # That is, Exception#to_s may not return a String instance if one wasn't # passed in upon creation of the Exception. So, try to generate a useful # String representation of the exception message, falling back to failsafe @message = String(@message.inspect) rescue '<unknown message type>' end # clamp long messages to 4k so that we don't send a lot of # overhead across the wire @message = @message[0..4095] if @message.length > 4096 # replace error message if enabled if OneApm::Manager.config[:'strip_exception_messages.enabled'] && !self.class.(exception.class) @message = OA_STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE end @timestamp = end |
Instance Attribute Details
#exception_class_name ⇒ Object
Returns the value of attribute exception_class_name.
10 11 12 |
# File 'lib/one_apm/errors/noticed_error.rb', line 10 def exception_class_name @exception_class_name end |
#exception_id ⇒ Object (readonly)
Returns the value of attribute exception_id.
11 12 13 |
# File 'lib/one_apm/errors/noticed_error.rb', line 11 def exception_id @exception_id end |
#is_internal ⇒ Object (readonly)
Returns the value of attribute is_internal.
11 12 13 |
# File 'lib/one_apm/errors/noticed_error.rb', line 11 def is_internal @is_internal end |
#message ⇒ Object
Returns the value of attribute message.
10 11 12 |
# File 'lib/one_apm/errors/noticed_error.rb', line 10 def @message end |
#params ⇒ Object
Returns the value of attribute params.
10 11 12 |
# File 'lib/one_apm/errors/noticed_error.rb', line 10 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/one_apm/errors/noticed_error.rb', line 10 def path @path end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
10 11 12 |
# File 'lib/one_apm/errors/noticed_error.rb', line 10 def @timestamp end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/one_apm/errors/noticed_error.rb', line 58 def ==(other) if other.respond_to?(:exception_id) exception_id == other.exception_id else false end end |
#to_collector_array(encoder = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/one_apm/errors/noticed_error.rb', line 72 def to_collector_array(encoder=nil) [ OneApm::Helper.time_to_millis(), string(path), string(), string(exception_class_name), params ] end |