recognizer 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,19 +18,15 @@ module Recognizer
18
18
  puts "Awaiting the metrics with impatience ..."
19
19
  queue.subscribe do |message|
20
20
  payload = message[:payload]
21
- begin
22
- metrics = JSON.parse(payload)
23
- if metrics.is_a?(Array)
24
- metrics.each do |metric|
25
- if metric.split(" ").count == 3
26
- thread_queue.push(metric)
27
- end
28
- end
29
- end
30
- rescue JSON::ParserError
31
- metric = payload
32
- if metric.split(" ").count == 3
33
- thread_queue.push(metric)
21
+ routing_key = message[:routing_key]
22
+ lines = payload.split("\n")
23
+ lines.each do |line|
24
+ line = line.strip
25
+ case line.split(" ").count
26
+ when 3
27
+ thread_queue.push(line)
28
+ when 2
29
+ thread_queue.push("#{routing_key} #{line}")
34
30
  end
35
31
  end
36
32
  end
@@ -31,9 +31,9 @@ module Recognizer
31
31
  loop do
32
32
  graphite_formated = thread_queue.pop
33
33
  puts "Adding metric to queue: #{graphite_formated}"
34
- metric = graphite_formated.split(" ")
34
+ metric, value, timestamp = graphite_formated.split(" ")
35
35
  mutex.synchronize do
36
- librato.add metric[0].to_sym => {:value => metric[1].to_f, :measure_time => metric[2].to_i}
36
+ librato.add metric.to_sym => {:value => value.to_f, :measure_time => timestamp.to_i}
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Recognizer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recognizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Porter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-29 00:00:00 -08:00
18
+ date: 2011-12-30 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency