Class: Eventoverse::BaseReporter
- Inherits:
-
Object
- Object
- Eventoverse::BaseReporter
- Includes:
- Singleton
- Defined in:
- lib/eventoverse/base_reporter.rb
Direct Known Subclasses
Class Method Summary collapse
-
.publish_message(*args) ⇒ Object
publish_message.
Instance Method Summary collapse
-
#publish_exception(exception, additional_info = {}) ⇒ Object
self.publish_message(*args).
-
#publish_message(event_type, attributes = {}, tags = []) ⇒ Object
API.
Class Method Details
.publish_message(*args) ⇒ Object
publish_message
33 34 35 |
# File 'lib/eventoverse/base_reporter.rb', line 33 def self.(*args) self.instance.(args) end |
Instance Method Details
#publish_exception(exception, additional_info = {}) ⇒ Object
self.publish_message(*args)
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/eventoverse/base_reporter.rb', line 37 def publish_exception(exception, additional_info = {}) backtrace = exception.backtrace backtrace_first_line = backtrace.first || "" md5_digest = Digest::MD5.hexdigest(backtrace_first_line) self.("exception", additional_info.merge({:backtrace_first_line => backtrace_first_line, :message => exception., :backtrace => backtrace.join("\n").slice(0..7000), :md5_digest => md5_digest })) rescue Exception => e puts "#{Time.now}: Can't publish exception, because of #{e.} \n #{e.backtrace.join}" end |
#publish_message(event_type, attributes = {}, tags = []) ⇒ Object
API
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/eventoverse/base_reporter.rb', line 18 def (event_type, attributes = {}, = []) payload = {:environment => Config.get_in(Eventoverse.config, [:env]), :application => Config.get_in(Eventoverse.config, [:application_name]), :hostname => Socket.gethostname, :tags => , :emitted_at => Time.now.to_i * 1000, :type => event_type || "exception"} payload.merge!(:additional_info => attributes) unless attributes.nil? (payload) rescue Exception => e puts "#{Time.now}: Can't publish the message (\n\tType: #{event_type}\n\tBody: #{payload.inspect}). \n\tDetails:#{e.inspect} \n\tBacktrace: #{e.backtrace}" end |