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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14c8492d53a5c59cdc5aac29799bd8f68f65e6a3
4
- data.tar.gz: f507be4c76cced41e1a341522d5e3f3887a9319a
3
+ metadata.gz: d3795d731081bacee9b35120d168a33510344cfb
4
+ data.tar.gz: 7ca9645cdc7ba74fd7d4cd0c9acca2339d08ff51
5
5
  SHA512:
6
- metadata.gz: 2302eb52dbe69f2cb0af57a5388c60f5a744e38bba5ef4d127d7a0ce312bdbb869df4dea21338c0f12756c14224c12b695e63e64418e45271bd9555edb396ef2
7
- data.tar.gz: 0f17e949e935de4ef4af47ad2a2f2061002cbe7a5965253b3166a4ea21dcb04d5292ffc63e47037434d3fc1a6bc90d550cee4f50862cf707bbf0a9120cad2787
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
- Logging support
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
@@ -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 Errno::EPIPE, Errno::EINVAL, Errno::ETIMEDOUT
35
+ rescue Exception
36
36
  @socket = nil
37
37
  (counter += 1) <= 5 ? retry : raise
38
38
  end
@@ -19,10 +19,10 @@ module GraphiteAPI
19
19
  attr_accessor :logger
20
20
 
21
21
  # :level => :debug
22
- # :std => out|err|file-name
22
+ # :dev => out|err|file-name
23
23
  def init(options)
24
- self.logger = ::Logger.new(options[:std] || STDOUT)
25
- self.logger.level= ::Logger.const_get "#{options[:level].to_s.upcase}"
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)
@@ -1,3 +1,3 @@
1
1
  module GraphiteAPI
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
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.1.8
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-03-26 00:00:00.000000000 Z
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.3
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.3
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: