metricsd 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.2 (July 27, 2011)
2
+
3
+ Bugfixes:
4
+
5
+ - Fixed problem in connection establishing code
6
+
1
7
  ## 0.2.1 (July 27, 2011)
2
8
 
3
9
  Bugfixes:
@@ -175,9 +175,8 @@ module Metricsd
175
175
 
176
176
  # Returns a UDP socket used to send metrics to MetricsD.
177
177
  def collector_socket
178
- @@socket ||= begin
179
- @@socket = UDPSocket.new
180
- @@socket.connect(Metricsd.server_host, Metricsd.server_port)
178
+ @@socket ||= UDPSocket.new.tap do |sock|
179
+ sock.connect(Metricsd.server_host, Metricsd.server_port)
181
180
  end
182
181
  end
183
182
 
@@ -203,17 +202,17 @@ module Metricsd
203
202
  end
204
203
 
205
204
  if msg.size + s.size + (msg.size > 0 ? 1 : 0) > 250
206
- safe_send_packet(msg)
205
+ safe_send(msg)
207
206
  msg = ''
208
207
  end
209
208
  msg << (msg.size > 0 ? ';' : '') << s
210
209
  end
211
- safe_send_packet(msg) if msg.size > 0
210
+ safe_send(msg) if msg.size > 0
212
211
  end
213
212
 
214
213
  # Sends a string to the MetricsD. Should never raise any network-specific
215
214
  # exceptions, but log them instead, and silently return.
216
- def safe_send_packet(msg)
215
+ def safe_send(msg)
217
216
  collector_socket.send(msg, 0)
218
217
  true
219
218
  rescue Errno::ECONNREFUSED => e
@@ -1,3 +1,3 @@
1
1
  module Metricsd
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -23,6 +23,13 @@ describe Metricsd::Client do
23
23
  @socket.should_not_receive(:send)
24
24
  Metricsd::Client.record_value('custom.metric', 5)
25
25
  end
26
+
27
+ it 'should create and cache UDPSocket in collector_socket method' do
28
+ Metricsd::Client.unstub!(:collector_socket)
29
+ sock = Metricsd::Client.send(:collector_socket)
30
+ sock.should be_a(UDPSocket)
31
+ Metricsd::Client.send(:collector_socket).should be(sock)
32
+ end
26
33
  end
27
34
 
28
35
  describe '.record_hit' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metricsd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmytro Shteflyuk