graphite-api 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -19
- data/lib/graphite-api/client.rb +3 -23
- data/lib/graphite-api/connector.rb +1 -1
- data/lib/graphite-api/logger.rb +3 -3
- data/lib/graphite-api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3795d731081bacee9b35120d168a33510344cfb
|
4
|
+
data.tar.gz: 7ca9645cdc7ba74fd7d4cd0c9acca2339d08ff51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c406a9bd20f842267022b51ce627e30850f1ccf1fbc35b49ac7522a02a1e6b64c3f6ca7e514287c5ddd053985ef1d2f5aa89cc3c616b2378213d4c90b1c1212a
|
7
|
+
data.tar.gz: 34d55c38be10cefbaa253889d6294941116612857a404145ae17bb1ba447149f381d0eef336bc999b046afd3cd04da4f3201ad563d2968917ae91b2db4762658
|
data/README.md
CHANGED
@@ -111,19 +111,6 @@ client.increment("jobs_in_queue", "num_errors", by: 20, time: Time.at(123456))
|
|
111
111
|
|
112
112
|
```
|
113
113
|
|
114
|
-
Some DSL sweetness
|
115
|
-
```ruby
|
116
|
-
require 'graphite-api'
|
117
|
-
|
118
|
-
client = GraphiteAPI.new( graphite: 'graphite:2003' )
|
119
|
-
|
120
|
-
client.webServer.web01.loadAvg 10.7
|
121
|
-
# => webServer.web01.loadAvg 10.7 time.now.to_i
|
122
|
-
|
123
|
-
client.webServer.web01.blaBlaBla(29.1, Time.at(9999999999))
|
124
|
-
# => webServer.web01.blaBlaBla 29.1 9999999999
|
125
|
-
```
|
126
|
-
|
127
114
|
Built-in timers support
|
128
115
|
```ruby
|
129
116
|
require 'graphite-api'
|
@@ -168,8 +155,7 @@ end
|
|
168
155
|
client.join # wait for ever...
|
169
156
|
```
|
170
157
|
|
171
|
-
|
172
|
-
|
158
|
+
Logger
|
173
159
|
```ruby
|
174
160
|
# Provide an external logger
|
175
161
|
require 'graphite-api'
|
@@ -179,10 +165,7 @@ GraphiteAPI::Logger.logger = ::Logger.new(STDOUT)
|
|
179
165
|
GraphiteAPI::Logger.logger.level = ::Logger::DEBUG
|
180
166
|
|
181
167
|
# Or use the built-in one
|
182
|
-
GraphiteAPI::Logger.init
|
183
|
-
:level => :debug,
|
184
|
-
:std => 'logger.out' # or STDOUT | STDERR
|
185
|
-
)
|
168
|
+
GraphiteAPI::Logger.init level: :debug, dev: 'logger.out' # or STDOUT | STDERR
|
186
169
|
```
|
187
170
|
|
188
171
|
## GraphiteAPI-Middleware Usage
|
data/lib/graphite-api/client.rb
CHANGED
@@ -11,7 +11,7 @@ module GraphiteAPI
|
|
11
11
|
@buffer = GraphiteAPI::Buffer.new options
|
12
12
|
@connectors = GraphiteAPI::Connector::Group.new options
|
13
13
|
|
14
|
-
Zscheduler.every(options[:interval]){ send_metrics } unless options[:direct]
|
14
|
+
Zscheduler.every(options[:interval]) { send_metrics } unless options[:direct]
|
15
15
|
end
|
16
16
|
|
17
17
|
def_delegator Zscheduler, :loop, :join
|
@@ -52,30 +52,8 @@ module GraphiteAPI
|
|
52
52
|
sleep while buffer.new_records?
|
53
53
|
end
|
54
54
|
|
55
|
-
def method_missing m, *args, &block
|
56
|
-
Proxy.new( self ).send(m,*args,&block)
|
57
|
-
end
|
58
|
-
|
59
55
|
protected
|
60
56
|
|
61
|
-
class Proxy
|
62
|
-
def initialize client
|
63
|
-
@client, @keys = client, []
|
64
|
-
end
|
65
|
-
|
66
|
-
def method_missing m, *args, &block
|
67
|
-
if @keys.push(m).size > 10
|
68
|
-
super # too deep
|
69
|
-
elsif args.any?
|
70
|
-
@client.metrics Hash[
|
71
|
-
@keys.join('.'), args.first
|
72
|
-
], *args[1..-1]
|
73
|
-
else
|
74
|
-
self
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
57
|
def validate options
|
80
58
|
options.tap do |opt|
|
81
59
|
raise ArgumentError.new ":graphite must be specified" if opt[:graphite].nil?
|
@@ -93,6 +71,8 @@ module GraphiteAPI
|
|
93
71
|
|
94
72
|
def send_metrics
|
95
73
|
connectors.publish buffer.pull :string if buffer.new_records?
|
74
|
+
rescue Exception => e
|
75
|
+
Zscheduler.init_reactor? ? raise : Logger.error("Publish Error: #{e}\n#{e.backtrace.join("\n")}")
|
96
76
|
end
|
97
77
|
|
98
78
|
end
|
@@ -32,7 +32,7 @@ module GraphiteAPI
|
|
32
32
|
begin
|
33
33
|
Logger.debug [:connector,:puts,[@host, @port].join(":"),message]
|
34
34
|
socket.puts message + "\n"
|
35
|
-
rescue
|
35
|
+
rescue Exception
|
36
36
|
@socket = nil
|
37
37
|
(counter += 1) <= 5 ? retry : raise
|
38
38
|
end
|
data/lib/graphite-api/logger.rb
CHANGED
@@ -19,10 +19,10 @@ module GraphiteAPI
|
|
19
19
|
attr_accessor :logger
|
20
20
|
|
21
21
|
# :level => :debug
|
22
|
-
# :
|
22
|
+
# :dev => out|err|file-name
|
23
23
|
def init(options)
|
24
|
-
self.logger = ::Logger.new(
|
25
|
-
self.logger.level= ::Logger.const_get
|
24
|
+
self.logger = ::Logger.new options.fetch(:dev, STDOUT)
|
25
|
+
self.logger.level= ::Logger.const_get options[:level].to_s.upcase
|
26
26
|
end
|
27
27
|
|
28
28
|
def method_missing(m,*args,&block)
|
data/lib/graphite-api/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.7
|
41
41
|
description: Graphite API - A Simple ruby client, aggregator daemon and API tools
|
42
42
|
email: eran@kontera.com
|
43
43
|
executables:
|