Class: Rstatsd::Collector
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Rstatsd::Collector
show all
- Includes:
- Helpers
- Defined in:
- lib/rstatsd/collector.rb
Instance Method Summary
collapse
Methods included from Helpers
#counter_key_name, #fetch_counters, #format_key, #redis, #redis_data_for, #timer_key_name
Constructor Details
Returns a new instance of Collector.
7
8
9
|
# File 'lib/rstatsd/collector.rb', line 7
def initialize
super
end
|
Instance Method Details
#post_init ⇒ Object
11
12
|
# File 'lib/rstatsd/collector.rb', line 11
def post_init
end
|
#receive_data(data) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rstatsd/collector.rb', line 14
def receive_data(data)
bits = data.split(':')
key = format_key(bits.first)
fields = bits.last.split("|")
case fields[1]
when 'c'
if fields[0] == '1'
value = redis.incr(key)
redis.rpush(counter_key_name(key), "#{value}:#{Time.now.to_i}")
elsif fields[0] == '-1'
value = redis.decr(key)
redis.rpush(counter_key_name(key), "#{value}:#{Time.now.to_i}")
end
redis.ltrim(counter_key_name(key), -10000, -1)
when 'ms'
redis.rpush(timer_key_name(key), "#{fields[0]}:#{Time.now.to_i}")
redis.ltrim(timer_key_name(key), -10000, -1)
else
end
end
|
#unbind ⇒ Object
38
39
|
# File 'lib/rstatsd/collector.rb', line 38
def unbind
end
|