Class: Hallmonitor::Event

Inherits:
Object
  • Object
show all
Includes:
Monitored
Defined in:
lib/hallmonitor/event.rb

Overview

The event class is a single-fire event, it most often represents a single, countable metric.

Direct Known Subclasses

GaugeEvent, TimedEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Monitored

#emit, included, #watch

Constructor Details

#initialize(name, count = 1) ⇒ Event

Builds a new event

Parameters:

  • name (String)

    the name of this event

  • count (Number) (defaults to: 1)

    the count of this even, defaults to 1



13
14
15
16
17
# File 'lib/hallmonitor/event.rb', line 13

def initialize(name, count=1)
  @name = name
  @time = Time.now
  @count = count
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



8
9
10
# File 'lib/hallmonitor/event.rb', line 8

def count
  @count
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/hallmonitor/event.rb', line 8

def name
  @name
end

#timeObject

Returns the value of attribute time.



8
9
10
# File 'lib/hallmonitor/event.rb', line 8

def time
  @time
end

Instance Method Details

#to_json(*a) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/hallmonitor/event.rb', line 19

def to_json(*a)
  {
    name: @name,
    time: @time,
    count: @count
  }.to_json(*a)
end