Class: InfluxReporter::ErrorMessage
- Inherits:
-
Object
- Object
- InfluxReporter::ErrorMessage
- Defined in:
- lib/influx_reporter/error_message.rb,
lib/influx_reporter/error_message/http.rb,
lib/influx_reporter/error_message/user.rb,
lib/influx_reporter/error_message/exception.rb,
lib/influx_reporter/error_message/stacktrace.rb
Defined Under Namespace
Classes: Exception, HTTP, Stacktrace, User
Constant Summary collapse
- DEFAULTS =
{ level: :error, logger: 'root' }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#culprit ⇒ Object
Returns the value of attribute culprit.
-
#database ⇒ Object
Returns the value of attribute database.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#http ⇒ Object
Returns the value of attribute http.
-
#level ⇒ Object
Returns the value of attribute level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#machine ⇒ Object
Returns the value of attribute machine.
-
#message ⇒ Object
Returns the value of attribute message.
-
#param_message ⇒ Object
Returns the value of attribute param_message.
-
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #add_extra(info) ⇒ Object
-
#initialize(config, message, attrs = {}) {|_self| ... } ⇒ ErrorMessage
constructor
A new instance of ErrorMessage.
Constructor Details
#initialize(config, message, attrs = {}) {|_self| ... } ⇒ ErrorMessage
Returns a new instance of ErrorMessage.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/influx_reporter/error_message.rb', line 20 def initialize(config, , attrs = {}) @config = config @message = @timestamp = Util.nanos DEFAULTS.merge(attrs).each do |k, v| send(:"#{k}=", v) end @filter = Filter.new config yield self if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
34 35 36 |
# File 'lib/influx_reporter/error_message.rb', line 34 def config @config end |
#culprit ⇒ Object
Returns the value of attribute culprit.
40 41 42 |
# File 'lib/influx_reporter/error_message.rb', line 40 def culprit @culprit end |
#database ⇒ Object
Returns the value of attribute database.
48 49 50 |
# File 'lib/influx_reporter/error_message.rb', line 48 def database @database end |
#exception ⇒ Object
Returns the value of attribute exception.
44 45 46 |
# File 'lib/influx_reporter/error_message.rb', line 44 def exception @exception end |
#extra ⇒ Object
Returns the value of attribute extra.
42 43 44 |
# File 'lib/influx_reporter/error_message.rb', line 42 def extra @extra end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
37 38 39 |
# File 'lib/influx_reporter/error_message.rb', line 37 def filter @filter end |
#http ⇒ Object
Returns the value of attribute http.
46 47 48 |
# File 'lib/influx_reporter/error_message.rb', line 46 def http @http end |
#level ⇒ Object
Returns the value of attribute level.
38 39 40 |
# File 'lib/influx_reporter/error_message.rb', line 38 def level @level end |
#logger ⇒ Object
Returns the value of attribute logger.
39 40 41 |
# File 'lib/influx_reporter/error_message.rb', line 39 def logger @logger end |
#machine ⇒ Object
Returns the value of attribute machine.
41 42 43 |
# File 'lib/influx_reporter/error_message.rb', line 41 def machine @machine end |
#message ⇒ Object
Returns the value of attribute message.
35 36 37 |
# File 'lib/influx_reporter/error_message.rb', line 35 def @message end |
#param_message ⇒ Object
Returns the value of attribute param_message.
43 44 45 |
# File 'lib/influx_reporter/error_message.rb', line 43 def @param_message end |
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
45 46 47 |
# File 'lib/influx_reporter/error_message.rb', line 45 def stacktrace @stacktrace end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
36 37 38 |
# File 'lib/influx_reporter/error_message.rb', line 36 def @timestamp end |
#user ⇒ Object
Returns the value of attribute user.
47 48 49 |
# File 'lib/influx_reporter/error_message.rb', line 47 def user @user end |
Class Method Details
.from_exception(config, exception, opts = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/influx_reporter/error_message.rb', line 50 def self.from_exception(config, exception, opts = {}) = "#{exception.class}: #{exception.}" if config.excluded_exceptions.include? exception.class.to_s info "Skipping excluded exception #{exception.class}" return nil end = new(config, ) do |msg| msg.level = :error msg.exception = Exception.from(exception) msg.stacktrace = Stacktrace.from(config, exception) end if frames = .stacktrace&.frames if first_frame = frames.last .culprit = "#{first_frame.filename}:#{first_frame.lineno}:in `#{first_frame.function}'" end end if env = opts[:rack_env] .http = HTTP.from_rack_env env, filter: .filter .user = User.from_rack_env config, env end if extra = opts[:extra] .extra = extra end end |
Instance Method Details
#add_extra(info) ⇒ Object
82 83 84 85 |
# File 'lib/influx_reporter/error_message.rb', line 82 def add_extra(info) @extra ||= {} @extra.deep_merge! info end |