hosted_graphite 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/hosted_graphite.rb +7 -2
- data/lib/hosted_graphite/version.rb +1 -1
- data/test/test_http_protocol.rb +4 -0
- data/test/test_tcp_protocol.rb +6 -1
- data/test/test_udp_protocol.rb +5 -1
- 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: 54635381836c0823f0c0372589924c3bee7ff317
|
|
4
|
+
data.tar.gz: ea2a81048ebe887e1947c573795050f71e5f7fb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da17091a4da06deb24e9e8634b9738dbcbd23ebc0b08bea239057ab640d567f5d8b4da500038a72910ea351756eb9696d7d699f7793d1fb4880d471a264e97b1
|
|
7
|
+
data.tar.gz: 47bb71c1f0f701670b727faa234b3505561f9fa9becc82f18f8fccaa867e9fc6ab8d0223143618ab4311389c8b4778f63ec2379ff7156da5dfe1f2a4caad4ca5
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
[](https://travis-ci.org/seuros/hosted_graphite)
|
|
2
2
|
[](https://codeclimate.com/github/seuros/hosted_graphite)
|
|
3
|
+
|
|
3
4
|
# HostedGraphite
|
|
4
5
|
|
|
5
6
|
A Ruby client for HostedGraphite
|
|
@@ -37,19 +38,19 @@ HostedGraphite.api_key = 'YOUR API KEY'
|
|
|
37
38
|
|
|
38
39
|
#### Sending a metric via UDP
|
|
39
40
|
```ruby
|
|
40
|
-
HostedGraphite.protocol =
|
|
41
|
+
HostedGraphite.protocol = :udp
|
|
41
42
|
HostedGraphite.send_metric('foo.udp', 1.2)
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
#### Sending a metric via TCP
|
|
45
46
|
```ruby
|
|
46
|
-
HostedGraphite.protocol =
|
|
47
|
+
HostedGraphite.protocol = :tcp
|
|
47
48
|
HostedGraphite.send_metric('foo.tcp', 1.2)
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
#### Sending a metric via HTTP
|
|
51
52
|
```ruby
|
|
52
|
-
HostedGraphite.protocol =
|
|
53
|
+
HostedGraphite.protocol = :http
|
|
53
54
|
HostedGraphite.send_metric('foo.http', 1.2)
|
|
54
55
|
```
|
|
55
56
|
|
|
@@ -80,7 +81,7 @@ HostedGraphite.timing 'foo', 320
|
|
|
80
81
|
HostedGraphite.gauge 'bar', 100
|
|
81
82
|
|
|
82
83
|
# Use {#time} to time the execution of a block
|
|
83
|
-
HostedGraphite.time('newsletter.monthly') { @
|
|
84
|
+
HostedGraphite.time('newsletter.monthly') { @newsletter.deliver_now }
|
|
84
85
|
```
|
|
85
86
|
|
|
86
87
|
## Contributing
|
data/lib/hosted_graphite.rb
CHANGED
|
@@ -32,8 +32,13 @@ module HostedGraphite
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def protocol=(protocol)
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
case protocol
|
|
36
|
+
when Class
|
|
37
|
+
@@protocol = protocol.new
|
|
38
|
+
when String, Symbol
|
|
39
|
+
protocol = protocol.to_s.upcase
|
|
40
|
+
@@protocol = const_get(protocol).new
|
|
41
|
+
end
|
|
37
42
|
end
|
|
38
43
|
end
|
|
39
44
|
end
|
data/test/test_http_protocol.rb
CHANGED
|
@@ -13,6 +13,10 @@ class HTTPProtocolTest < Minitest::Test
|
|
|
13
13
|
HostedGraphite.api_key = @previous_api_key
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def test_http_protocol
|
|
17
|
+
assert_instance_of HostedGraphite::HTTP, HostedGraphite.protocol
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
def test_correct_query
|
|
17
21
|
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
|
18
22
|
assert_equal 'foo 1.2 1421792423', query
|
data/test/test_tcp_protocol.rb
CHANGED
|
@@ -2,17 +2,22 @@ require_relative 'helper'
|
|
|
2
2
|
|
|
3
3
|
class TCPProtocolTest < Minitest::Test
|
|
4
4
|
attr_reader :api_key
|
|
5
|
+
|
|
5
6
|
def setup
|
|
6
7
|
@previous_api_key = HostedGraphite.api_key
|
|
7
8
|
@api_key = SecureRandom.uuid
|
|
8
9
|
HostedGraphite.api_key = @api_key
|
|
9
|
-
HostedGraphite.protocol =
|
|
10
|
+
HostedGraphite.protocol = 'tcp'
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def teardown
|
|
13
14
|
HostedGraphite.api_key = @previous_api_key
|
|
14
15
|
end
|
|
15
16
|
|
|
17
|
+
def test_tcp_protocol
|
|
18
|
+
assert_instance_of HostedGraphite::TCP, HostedGraphite.protocol
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
def test_correct_query
|
|
17
22
|
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
|
18
23
|
assert_equal "#{api_key}.foo 1.2 1421792423\n", query
|
data/test/test_udp_protocol.rb
CHANGED
|
@@ -6,13 +6,17 @@ class UDPProtocolTest < Minitest::Test
|
|
|
6
6
|
@previous_api_key = HostedGraphite.api_key
|
|
7
7
|
@api_key = SecureRandom.uuid
|
|
8
8
|
HostedGraphite.api_key = @api_key
|
|
9
|
-
HostedGraphite.protocol =
|
|
9
|
+
HostedGraphite.protocol = :udp
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def teardown
|
|
13
13
|
HostedGraphite.api_key = @previous_api_key
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def test_udp_protocol
|
|
17
|
+
assert_instance_of HostedGraphite::UDP, HostedGraphite.protocol
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
def test_correct_query
|
|
17
21
|
query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
|
|
18
22
|
assert_equal "#{api_key}.foo 1.2 1421792423\n", query
|
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.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abdelkader Boudih
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-01-
|
|
11
|
+
date: 2015-01-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|