graphite-api 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7f26c3b31d445c4e11d556609f0c3b600c60fe7
4
- data.tar.gz: 657df67acbef98202c7278e473994b4bd47841f9
3
+ metadata.gz: 971a57f1632c01fa383fcafd604fb0c020e55039
4
+ data.tar.gz: b49356560ef58767756cb38c5110685307ec5113
5
5
  SHA512:
6
- metadata.gz: 4e464886000e85f88d21dd6351d60e3160a3dc9b4e66b4d98f72f7fd3ae1f50556494843c21b3430d1d26aa11ed2c7c9d23dcf36bd8b7177a1dc804e07811d91
7
- data.tar.gz: 8cba41ac302987b045af13b8ef025ff08b9c93e49353442e38edbd7b8db66ec70c4f538ec4f6aff4d125e2f777972aef5bc1b7b5a20b2104863e1803573e183a
6
+ metadata.gz: 0a31a71042953ac8b4cee6c23f29b934f6202b2e0f609a6b80b99d20b122683461f2a6e2bdb8ae25fb8fb07ebe5d6239499390c8beee2f329003656e8cdbc29d
7
+ data.tar.gz: 4e4d60ccf3f79cf80af1efad3018731f99e252c02ec0e281e6ec6414ee53c7e9b4fe66a8e19ad5f906a33ca7d9b25ec897d0c5299afd794ff5115a8ea97f92ac
data/README.md CHANGED
@@ -41,19 +41,40 @@ rake install
41
41
  ```
42
42
 
43
43
  ## Client Usage
44
- Creating a new client instance
44
+
45
+ Creating a new UDP client
45
46
 
46
47
  ```ruby
47
48
  require 'graphite-api'
48
49
 
49
- GraphiteAPI.new(
50
- graphite: "udp://graphite.example.com:2003", # required argument
51
- prefix: ["example","prefix"], # add example.prefix to each key
52
- slice: 60, # results are aggregated in 60 seconds slices
53
- interval: 60, # send to graphite every 60 seconds
54
- # default is 0 ( direct send )
55
- cache: 4 * 60 * 60 # set the max age in seconds for records reanimation
56
- )
50
+ options = {
51
+ # Required: valid URI {udp,tcp}://host:port/?timeout=seconds
52
+ graphite: "udp://graphite.example.com:2003",
53
+
54
+ # Optional: add example.prefix to each key
55
+ prefix: ["example","prefix"],
56
+
57
+ # Optional: results are aggregated in 60 seconds slices ( default is 60 )
58
+ slice: 60,
59
+
60
+ # Optional: send to graphite every 60 seconds ( default is 0 - direct send )
61
+ interval: 60,
62
+
63
+ # Optional: set the max age in seconds for records reanimation ( default is 12 hours )
64
+ cache: 4 * 60 * 60
65
+ }
66
+
67
+ client = GraphiteAPI.new options
68
+ ```
69
+
70
+ TCP Client
71
+ ```ruby
72
+ client = GraphiteAPI.new graphite: "tcp://graphite.example.com:2003"
73
+ ```
74
+
75
+ TCP Client with 30 seconds timeout
76
+ ```ruby
77
+ client = GraphiteAPI.new graphite: "tcp://graphite.example.com:2003?timeout=30"
57
78
  ```
58
79
 
59
80
  Adding simple metrics
@@ -226,11 +247,6 @@ client.bla.bla.value2 27
226
247
  <br/>
227
248
  <img src="https://raw.github.com/kontera-technologies/graphite-api/master/examples/middleware_t1.png" align="center">
228
249
 
229
- ## TODO:
230
- * Better documentation
231
- * Use Redis for caching
232
- * Multiple backends via client as well
233
-
234
250
  ## Bugs
235
251
 
236
252
  If you find a bug, feel free to report it @ our [issues tracker](https://github.com/kontera-technologies/graphite-api/issues) on github.
@@ -45,7 +45,7 @@ module GraphiteAPI
45
45
  def socket
46
46
  @socket ||= begin
47
47
  host, port = @uri.host, @uri.port
48
- timeout = Hash[URI.decode_www_form(@uri.query.to_s)].fetch("timeout", 1)
48
+ timeout = Hash[URI.decode_www_form(@uri.query.to_s)].fetch("timeout", 1).to_f
49
49
  addr = Socket.getaddrinfo host, nil, :INET
50
50
  sockaddr = Socket.pack_sockaddr_in port, addr[0][3]
51
51
 
@@ -79,7 +79,7 @@ module GraphiteAPI
79
79
  end
80
80
 
81
81
  def publish messages
82
- Logger.debug [:connector_group, :publish, messages, @connectors]
82
+ Logger.debug [:connector_group, :publish, messages.size, @connectors]
83
83
  Array(messages).each { |msg| @connectors.map {|c| c.puts msg} }
84
84
  end
85
85
  end
@@ -94,7 +94,7 @@ module GraphiteAPI
94
94
  def puts message
95
95
  counter = 0
96
96
  begin
97
- Logger.debug [:connector, :puts, @uri, message]
97
+ Logger.debug [:connector, :puts, @uri.to_s, message]
98
98
  socket.puts message + "\n"
99
99
  rescue Exception
100
100
  @socket = nil
@@ -102,11 +102,14 @@ module GraphiteAPI
102
102
  end
103
103
  end
104
104
 
105
+ def inspect
106
+ "#<#{self.class}:#{object_id}: #{@uri}>"
107
+ end
108
+
105
109
  private
106
110
 
107
111
  def socket
108
112
  if @socket.nil? || @socket.closed?
109
- Logger.debug [:connector, :init, @uri]
110
113
  @socket = @uri.scheme.eql?("tcp") ? TCPSocket.new(@uri) : UDPSocket.new(@uri)
111
114
  end
112
115
  @socket
@@ -1,3 +1,3 @@
1
1
  module GraphiteAPI
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphite-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eran Barak Levi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-25 00:00:00.000000000 Z
11
+ date: 2018-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine