hosted_graphite 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hosted_graphite/protocol.rb +9 -5
- data/lib/hosted_graphite/tcp.rb +2 -2
- data/lib/hosted_graphite/udp.rb +2 -2
- data/lib/hosted_graphite/version.rb +1 -1
- data/test/test_http_protocol.rb +2 -2
- data/test/test_tcp_protocol.rb +2 -2
- data/test/test_udp_protocol.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5436f82e5b70c838801d306685513bf9afdd7691
|
4
|
+
data.tar.gz: 75cae3e795e3b762258f2f5953ca988fada3921e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b437897dbd4f2ca251c795d07bab35c7d75d588261026bc1c343a3a28677853a1bf5d365d669b11ddabafe6536fd23e3a2b81ade96f93cff3f126dd490be88
|
7
|
+
data.tar.gz: 450ccbc22c3a6c05811e314ec04c9c710f68e44d5b18c641fb7a928899377268a007a51bcc8b95bd1763ec71101a012c7455090cc76a0a994ee7dbf4a0fe0e2b
|
@@ -11,9 +11,8 @@ module HostedGraphite
|
|
11
11
|
@api_key = HostedGraphite.api_key
|
12
12
|
end
|
13
13
|
|
14
|
-
def send_metric(name, value)
|
15
|
-
|
16
|
-
send_message(msg)
|
14
|
+
def send_metric(name, value, timestamp = nil)
|
15
|
+
send_message(build_message(name, value, timestamp))
|
17
16
|
rescue => e
|
18
17
|
# set HOSTEDGRAPHITE_DEBUG to to raise errors instead of silencing them.
|
19
18
|
raise e if ENV['HOSTEDGRAPHITE_DEBUG']
|
@@ -21,8 +20,13 @@ module HostedGraphite
|
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
|
-
|
25
|
-
|
23
|
+
|
24
|
+
def build_message(name, value, timestamp = nil)
|
25
|
+
unless timestamp
|
26
|
+
return [name, value].join ' '
|
26
27
|
end
|
28
|
+
|
29
|
+
[name, value, timestamp].join ' '
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
data/lib/hosted_graphite/tcp.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module HostedGraphite
|
2
2
|
class TCP < Protocol
|
3
3
|
private
|
4
|
-
def build_message(name, value)
|
5
|
-
message = [name, value].join(' ') + "\n"
|
4
|
+
def build_message(name, value, timestamp = nil)
|
5
|
+
message = [name, value, timestamp].compact.join(' ') + "\n"
|
6
6
|
[@api_key, message].join('.')
|
7
7
|
end
|
8
8
|
|
data/lib/hosted_graphite/udp.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module HostedGraphite
|
2
2
|
class UDP < Protocol
|
3
3
|
private
|
4
|
-
def build_message(name, value)
|
5
|
-
message = [name, value].join(' ') + "\n"
|
4
|
+
def build_message(name, value, timestamp = nil)
|
5
|
+
message = [name, value, timestamp].compact.join(' ') + "\n"
|
6
6
|
[@api_key, message].join('.')
|
7
7
|
end
|
8
8
|
|
data/test/test_http_protocol.rb
CHANGED
@@ -15,7 +15,7 @@ class HTTPProtocolTest < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_correct_query
|
18
|
-
query = HostedGraphite.send_metric('foo', 1.2)
|
19
|
-
assert_equal 'foo 1.2', query
|
18
|
+
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
19
|
+
assert_equal 'foo 1.2 1421792423', query
|
20
20
|
end
|
21
21
|
end
|
data/test/test_tcp_protocol.rb
CHANGED
@@ -15,7 +15,7 @@ class TCPProtocolTest < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_correct_query
|
18
|
-
query = HostedGraphite.send_metric('foo', 1.2)
|
19
|
-
assert_equal "#{api_key}.foo 1.2\n", query
|
18
|
+
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
19
|
+
assert_equal "#{api_key}.foo 1.2 1421792423\n", query
|
20
20
|
end
|
21
21
|
end
|
data/test/test_udp_protocol.rb
CHANGED
@@ -15,7 +15,7 @@ class UDPProtocolTest < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_correct_query
|
18
|
-
query = HostedGraphite.send_metric('foo', 1.2)
|
19
|
-
assert_equal "#{api_key}.foo 1.2\n", query
|
18
|
+
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
19
|
+
assert_equal "#{api_key}.foo 1.2 1421792423\n", query
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hosted_graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|