Class: Hallmonitor::GaugeEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/hallmonitor/gauge_event.rb

Overview

A Gauge event is an event that has a specific value, think of it like a tachometer or gas gauge on a car: at any given point it reports the current value of a variable.

Instance Attribute Summary

Attributes inherited from Event

#count, #name, #tags, #time

Instance Method Summary collapse

Methods included from Monitored

#emit, included, #watch

Constructor Details

#initialize(name, value: nil, tags: {}) ⇒ GaugeEvent

Returns a new instance of GaugeEvent.

Parameters:

  • name (String)

    Name of this guage

  • value (Number) (defaults to: nil)

    The current value of this guage



9
10
11
# File 'lib/hallmonitor/gauge_event.rb', line 9

def initialize(name, value: nil, tags: {})
  super(name, count: value, tags: tags)
end

Instance Method Details

#to_json(*a) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/hallmonitor/gauge_event.rb', line 24

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

#valueObject

The value of this guage



14
15
16
# File 'lib/hallmonitor/gauge_event.rb', line 14

def value
  count
end

#value=(new_value) ⇒ Object

Sets the value of this guage

Parameters:

  • new_value (Number)


20
21
22
# File 'lib/hallmonitor/gauge_event.rb', line 20

def value=(new_value)
  self.count = new_value
end