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, tags: {}) ⇒ Event

Builds a new event

Parameters:

  • name (String)

    the name of this event

  • count (Number, Hash) (defaults to: 1)

    the count of this even, defaults to 1. Can also be a hash of named value pairs

  • tags (Hash<Symbol,String>) (defaults to: {})

    Hash of tags to values for this event



15
16
17
18
19
20
# File 'lib/hallmonitor/event.rb', line 15

def initialize(name, count: 1, tags: {})
  @name = name
  @time = Time.now
  @count = count
  @tags = tags
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

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
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



22
23
24
25
26
27
28
29
# File 'lib/hallmonitor/event.rb', line 22

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