recognizer 0.1.5 → 0.1.6
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.
- data/lib/recognizer/amqp.rb +4 -0
- data/lib/recognizer/config.rb +2 -2
- data/lib/recognizer/librato.rb +9 -2
- data/lib/recognizer/patches/hash.rb +6 -16
- data/lib/recognizer/patches/openssl.rb +8 -0
- data/lib/recognizer/version.rb +1 -1
- data/recognizer.gemspec +1 -1
- metadata +10 -8
data/lib/recognizer/amqp.rb
CHANGED
data/lib/recognizer/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "json"
|
3
3
|
|
4
|
-
require File.join(File.dirname(__FILE__),
|
4
|
+
require File.join(File.dirname(__FILE__), "patches", "hash")
|
5
5
|
|
6
6
|
module Recognizer
|
7
7
|
class Config
|
@@ -10,7 +10,7 @@ module Recognizer
|
|
10
10
|
raise "Missing config file path"
|
11
11
|
end
|
12
12
|
if File.readable?(options[:config_file])
|
13
|
-
config_file_contents = File.open(options[:config_file],
|
13
|
+
config_file_contents = File.open(options[:config_file], "r").read
|
14
14
|
begin
|
15
15
|
@config = JSON.parse(config_file_contents)
|
16
16
|
rescue JSON::ParserError => error
|
data/lib/recognizer/librato.rb
CHANGED
@@ -3,7 +3,11 @@ require "recognizer/version"
|
|
3
3
|
require "thread"
|
4
4
|
require "librato/metrics"
|
5
5
|
|
6
|
-
require File.join(File.dirname(__FILE__),
|
6
|
+
require File.join(File.dirname(__FILE__), "patches", "float")
|
7
|
+
|
8
|
+
if RUBY_PLATFORM == "java"
|
9
|
+
require File.join(File.dirname(__FILE__), "patches", "openssl")
|
10
|
+
end
|
7
11
|
|
8
12
|
module Recognizer
|
9
13
|
class Librato
|
@@ -30,11 +34,11 @@ module Recognizer
|
|
30
34
|
mutex.synchronize do
|
31
35
|
begin
|
32
36
|
librato.submit
|
37
|
+
logger.info("Successfully flushed metrics to Librato")
|
33
38
|
rescue => error
|
34
39
|
logger.error("Encountered an error when flushing metrics to Librato :: #{error}")
|
35
40
|
end
|
36
41
|
end
|
37
|
-
logger.info("Successfully flushed metrics to Librato")
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
@@ -62,6 +66,9 @@ module Recognizer
|
|
62
66
|
unless parts.first =~ /^[A-Za-z0-9\._-]*$/
|
63
67
|
raise "metric name must only consist of alpha-numeric characters, periods, underscores, and dashes"
|
64
68
|
end
|
69
|
+
unless parts.last =~ /^[0-9]{10}$/
|
70
|
+
raise "metric timestamp must be epoch, 10 digits"
|
71
|
+
end
|
65
72
|
|
66
73
|
path = parts.shift.split(".")
|
67
74
|
value = Float(parts.shift).pretty
|
@@ -1,20 +1,10 @@
|
|
1
1
|
class Hash
|
2
|
-
def symbolize_keys
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
when Hash
|
9
|
-
Hash[
|
10
|
-
item.map do |key, value|
|
11
|
-
new_key = key.is_a?(String) ? key.to_sym : key
|
12
|
-
new_value = symbolize_keys(value)
|
13
|
-
[new_key, new_value]
|
14
|
-
end
|
15
|
-
]
|
16
|
-
else
|
17
|
-
item
|
2
|
+
def symbolize_keys
|
3
|
+
inject(Hash.new) do |result, (key, value)|
|
4
|
+
new_key = key.is_a?(String) ? key.to_sym : key
|
5
|
+
new_value = value.is_a?(Hash) ? value.symbolize_keys : value
|
6
|
+
result[new_key] = new_value
|
7
|
+
result
|
18
8
|
end
|
19
9
|
end
|
20
10
|
end
|
data/lib/recognizer/version.rb
CHANGED
data/recognizer.gemspec
CHANGED
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
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: 2012-04-
|
18
|
+
date: 2012-04-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -72,12 +72,13 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
75
|
+
hash: -1876988210
|
76
76
|
segments:
|
77
77
|
- 0
|
78
|
-
-
|
79
|
-
-
|
80
|
-
|
78
|
+
- 6
|
79
|
+
- 0
|
80
|
+
- pre3
|
81
|
+
version: 0.6.0.pre3
|
81
82
|
type: :runtime
|
82
83
|
version_requirements: *id004
|
83
84
|
description: A drop-in replacement for Graphite Carbon (TCP & AMQP), sending metrics to Librato Metrics.
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- lib/recognizer/librato.rb
|
98
99
|
- lib/recognizer/patches/float.rb
|
99
100
|
- lib/recognizer/patches/hash.rb
|
101
|
+
- lib/recognizer/patches/openssl.rb
|
100
102
|
- lib/recognizer/tcp.rb
|
101
103
|
- lib/recognizer/version.rb
|
102
104
|
- lib/recognizer.rb
|