class Rnotifier::EventData

Constants

ALERT
EVENT

Attributes

data[R]

Public Class Methods

app_env() click to toggle source
# File lib/rnotifier/event_data.rb, line 33
def self.app_env
  @app_env ||= {
    :env => Config.current_env,
    :pid => $$,
    :host => (Socket.gethostname rescue ''),
    :language => 'ruby',
    :timezone => (Time.now.zone rescue nil)
  }
end
new(name, type, data = {}, tags = nil) click to toggle source
# File lib/rnotifier/event_data.rb, line 8
def initialize(name, type, data = {}, tags = nil)
  @data = {
    :name => name, 
    :data => data,
    :app_env => EventData.app_env,
    :occurred_at => Time.now.to_i,
    :rnotifier_client => Config::CLIENT,
    :type => type,
  }

  @data[:tags] = tags if tags
end

Public Instance Methods

notify() click to toggle source
# File lib/rnotifier/event_data.rb, line 21
def notify
  return false unless Config.valid?

  begin
    Notifier.send(data, Config.event_path)
  rescue Exception => e
    Rlogger.error("[EVENT NOTIFY] #{e.message}")
    Rlogger.error("[EVENT NOTIFY] #{e.backtrace}")
    false
  end
end