Class: Rnotifier::EventData

Inherits:
Object
  • Object
show all
Defined in:
lib/rnotifier/event_data.rb

Constant Summary collapse

EVENT =
0
ALERT =
1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, data = {}) ⇒ EventData

Returns a new instance of EventData.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rnotifier/event_data.rb', line 8

def initialize(name, type, data = {})
  @data = {
    :name => name, 
    :data => data,
    :app_env => EventData.app_env,
    :occurred_at => Time.now.utc.to_s,
    :rnotifier_client => Config::CLIENT,
    :type => type,
  }
  @data[:context_data] = Thread.current[:rnotifier_context] if Thread.current[:rnotifier_context]
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/rnotifier/event_data.rb', line 3

def data
  @data
end

Class Method Details

.app_envObject



29
30
31
# File 'lib/rnotifier/event_data.rb', line 29

def self.app_env
  @env ||= Rnotifier::Config.event_app_env 
end

Instance Method Details

#notifyObject



20
21
22
23
24
25
26
27
# File 'lib/rnotifier/event_data.rb', line 20

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