Class: FnordMetric::Gauge
Instance Method Summary
collapse
#render_to_event, #renderable?
#validate_series!
#assure_has_series!, #assure_non_progressive!, #assure_series_exists!, #assure_three_dimensional!, #assure_two_dimensional!, #incr, #incr_avg, #incr_denominator, #incr_field, #incr_field_by, #incr_fraction, #incr_numerator, #incr_tick, #incr_uniq, #parse_numeric, #set_field, #set_value
#calculate_value, #field_values_at, #field_values_total, #fraction_values_in, #ticks_in, #value_at, #values_at, #values_in
Constructor Details
#initialize(opts) ⇒ Gauge
Returns a new instance of Gauge.
8
9
10
11
|
# File 'lib/fnordmetric/gauge.rb', line 8
def initialize(opts)
opts.fetch(:key) && opts.fetch(:key_prefix)
@opts = opts
end
|
Instance Method Details
#average? ⇒ Boolean
78
79
80
|
# File 'lib/fnordmetric/gauge.rb', line 78
def average?
!!@opts[:average]
end
|
#error!(msg) ⇒ Object
94
95
96
|
# File 'lib/fnordmetric/gauge.rb', line 94
def error!(msg)
FnordMetric.error(msg)
end
|
#group ⇒ Object
34
35
36
|
# File 'lib/fnordmetric/gauge.rb', line 34
def group
@opts[:group] || "Gauges"
end
|
#has_series? ⇒ Boolean
82
83
84
|
# File 'lib/fnordmetric/gauge.rb', line 82
def has_series?
false
end
|
#key(_append = nil) ⇒ Object
46
47
48
|
# File 'lib/fnordmetric/gauge.rb', line 46
def key(_append=nil)
[@opts[:key_prefix], "gauge", name, tick, _append].flatten.compact.join("-")
end
|
#key_nouns ⇒ Object
42
43
44
|
# File 'lib/fnordmetric/gauge.rb', line 42
def key_nouns
@opts[:key_nouns] || ["Key", "Keys"]
end
|
#name ⇒ Object
26
27
28
|
# File 'lib/fnordmetric/gauge.rb', line 26
def name
@opts[:key]
end
|
#progressive? ⇒ Boolean
70
71
72
|
# File 'lib/fnordmetric/gauge.rb', line 70
def progressive?
!!@opts[:progressive]
end
|
#redis ⇒ Object
86
87
88
|
# File 'lib/fnordmetric/gauge.rb', line 86
def redis
@redis ||= EM::Hiredis.connect(FnordMetric.options[:redis_url]) end
|
#retention ⇒ Object
18
19
20
|
# File 'lib/fnordmetric/gauge.rb', line 18
def retention
tick * 10 end
|
#retention_key(_time, _append = nil) ⇒ Object
58
59
60
|
# File 'lib/fnordmetric/gauge.rb', line 58
def retention_key(_time, _append=nil)
key([tick_at(_time, retention).to_s, _append])
end
|
#sync_redis ⇒ Object
90
91
92
|
# File 'lib/fnordmetric/gauge.rb', line 90
def sync_redis
@sync_redis ||= FnordMetric.mk_redis end
|
#three_dimensional? ⇒ Boolean
66
67
68
|
# File 'lib/fnordmetric/gauge.rb', line 66
def three_dimensional?
!!@opts[:three_dimensional]
end
|
#tick ⇒ Object
13
14
15
16
|
# File 'lib/fnordmetric/gauge.rb', line 13
def tick
(@opts[:tick] || @opts[:resolution] || @opts[:flush_interval] ||
FnordMetric.options[:default_flush_interval]).to_i
end
|
#tick_at(time, _tick = tick) ⇒ Object
22
23
24
|
# File 'lib/fnordmetric/gauge.rb', line 22
def tick_at(time, _tick=tick)
(time/_tick.to_f).floor*_tick
end
|
#tick_key(_time, _append = nil) ⇒ Object
50
51
52
|
# File 'lib/fnordmetric/gauge.rb', line 50
def tick_key(_time, _append=nil)
key([(progressive? ? :progressive : tick_at(_time).to_s), _append])
end
|
#tick_keys(_range, _append = nil) ⇒ Object
54
55
56
|
# File 'lib/fnordmetric/gauge.rb', line 54
def tick_keys(_range, _append=nil)
ticks_in(_range).map{ |_t| tick_key(_t, _append) }
end
|
#title ⇒ Object
30
31
32
|
# File 'lib/fnordmetric/gauge.rb', line 30
def title
@opts[:title] || name
end
|
#two_dimensional? ⇒ Boolean
62
63
64
|
# File 'lib/fnordmetric/gauge.rb', line 62
def two_dimensional?
!@opts[:three_dimensional]
end
|
#unique? ⇒ Boolean
74
75
76
|
# File 'lib/fnordmetric/gauge.rb', line 74
def unique?
!!@opts[:unique]
end
|
#unit ⇒ Object
38
39
40
|
# File 'lib/fnordmetric/gauge.rb', line 38
def unit
@opts[:unit]
end
|