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 +6 -0
- data/lib/metricsd/client.rb +5 -6
- data/lib/metricsd/version.rb +1 -1
- data/spec/client_spec.rb +7 -0
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/lib/metricsd/client.rb
CHANGED
@@ -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 ||=
|
179
|
-
|
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
|
-
|
205
|
+
safe_send(msg)
|
207
206
|
msg = ''
|
208
207
|
end
|
209
208
|
msg << (msg.size > 0 ? ';' : '') << s
|
210
209
|
end
|
211
|
-
|
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
|
215
|
+
def safe_send(msg)
|
217
216
|
collector_socket.send(msg, 0)
|
218
217
|
true
|
219
218
|
rescue Errno::ECONNREFUSED => e
|
data/lib/metricsd/version.rb
CHANGED
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmytro Shteflyuk
|