statsd-ruby 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/README.rdoc +16 -2
- data/lib/statsd.rb +21 -1
- data/spec/statsd_spec.rb +33 -0
- data/statsd-ruby.gemspec +2 -2
- metadata +5 -5
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -35,7 +35,7 @@ Run the specs and include live integration specs with <tt>LIVE=true rake spec</t
|
|
35
35
|
* A short note about DNS: If you use a dns name for the host option, then you will want to use a local caching dns service for optimial performance (e.g. nscd).
|
36
36
|
|
37
37
|
== Contributing to statsd
|
38
|
-
|
38
|
+
|
39
39
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
40
40
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
41
41
|
* Fork the project
|
@@ -55,7 +55,21 @@ Run the specs and include live integration specs with <tt>LIVE=true rake spec</t
|
|
55
55
|
* Trae Robrock
|
56
56
|
* Corey Donohoe
|
57
57
|
* James Tucker
|
58
|
+
* Dotan Nahum
|
59
|
+
* Eric Chapweske
|
60
|
+
* Hannes Georg
|
61
|
+
* John Nunemaker
|
62
|
+
* Mahesh Murthy
|
63
|
+
* Manu J
|
64
|
+
* Matt Sanford
|
65
|
+
* Nate Bird
|
66
|
+
* Noah Lorang
|
67
|
+
* Oscar Del Ben
|
68
|
+
* Peter Mounce
|
69
|
+
* Ray Krueger
|
70
|
+
* Reed Lipman
|
71
|
+
* Thomas Whaples
|
58
72
|
|
59
73
|
== Copyright
|
60
74
|
|
61
|
-
Copyright (c) 2011 Rein Henrichs. See LICENSE.txt for further details.
|
75
|
+
Copyright (c) 2011, 2012, 2013 Rein Henrichs. See LICENSE.txt for further details.
|
data/lib/statsd.rb
CHANGED
@@ -43,7 +43,11 @@ class Statsd
|
|
43
43
|
|
44
44
|
extend Forwardable
|
45
45
|
def_delegators :@statsd,
|
46
|
-
:namespace, :namespace=,
|
46
|
+
:namespace, :namespace=,
|
47
|
+
:host, :host=,
|
48
|
+
:port, :port=,
|
49
|
+
:prefix,
|
50
|
+
:postfix
|
47
51
|
|
48
52
|
attr_accessor :batch_size
|
49
53
|
|
@@ -187,6 +191,22 @@ class Statsd
|
|
187
191
|
send_stats stat, value, :g, sample_rate
|
188
192
|
end
|
189
193
|
|
194
|
+
# Sends an arbitary set value for the given stat to the statsd server.
|
195
|
+
#
|
196
|
+
# This is for recording counts of unique events, which are useful to
|
197
|
+
# see on graphs to correlate to other values. For example, a deployment
|
198
|
+
# might get recorded as a set, and be drawn as annotations on a CPU history
|
199
|
+
# graph.
|
200
|
+
#
|
201
|
+
# @param [String] stat stat name.
|
202
|
+
# @param [Numeric] value event value.
|
203
|
+
# @param [Numeric] sample_rate sample rate, 1 for always
|
204
|
+
# @example Report a deployment happening:
|
205
|
+
# $statsd.set('deployment', DEPLOYMENT_EVENT_CODE)
|
206
|
+
def set(stat, value, sample_rate=1)
|
207
|
+
send_stats stat, value, :s, sample_rate
|
208
|
+
end
|
209
|
+
|
190
210
|
# Sends a timing (in ms) for the given stat to the statsd server. The
|
191
211
|
# sample_rate determines what percentage of the time this report is sent. The
|
192
212
|
# statsd server then uses the sample_rate to correctly track the average
|
data/spec/statsd_spec.rb
CHANGED
@@ -111,6 +111,21 @@ describe Statsd do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
describe "#set" do
|
115
|
+
it "should format the message according to the statsd spec" do
|
116
|
+
@statsd.set('foobar', 765)
|
117
|
+
@socket.recv.must_equal ['foobar:765|s']
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "with a sample rate" do
|
121
|
+
before { class << @statsd; def rand; 0; end; end } # ensure delivery
|
122
|
+
it "should format the message according to the statsd spec" do
|
123
|
+
@statsd.set('foobar', 500, 0.5)
|
124
|
+
@socket.recv.must_equal ['foobar:500|s|@0.5']
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
114
129
|
describe "#time" do
|
115
130
|
it "should format the message according to the statsd spec" do
|
116
131
|
@statsd.time('foobar') { 'test' }
|
@@ -318,6 +333,24 @@ describe Statsd do
|
|
318
333
|
@socket.recv.must_equal %w[foobar:1|c]
|
319
334
|
end
|
320
335
|
|
336
|
+
it "should support setting namespace for the underlying instance" do
|
337
|
+
batch = Statsd::Batch.new(@statsd)
|
338
|
+
batch.namespace = 'ns'
|
339
|
+
@statsd.namespace.must_equal 'ns'
|
340
|
+
end
|
341
|
+
|
342
|
+
it "should support setting host for the underlying instance" do
|
343
|
+
batch = Statsd::Batch.new(@statsd)
|
344
|
+
batch.host = '1.2.3.4'
|
345
|
+
@statsd.host.must_equal '1.2.3.4'
|
346
|
+
end
|
347
|
+
|
348
|
+
it "should support setting port for the underlying instance" do
|
349
|
+
batch = Statsd::Batch.new(@statsd)
|
350
|
+
batch.port = 42
|
351
|
+
@statsd.port.must_equal 42
|
352
|
+
end
|
353
|
+
|
321
354
|
end
|
322
355
|
|
323
356
|
describe "thread safety" do
|
data/statsd-ruby.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
Gem::Specification.new("statsd-ruby", "1.
|
3
|
+
Gem::Specification.new("statsd-ruby", "1.2.0") do |s|
|
4
4
|
s.authors = ["Rein Henrichs"]
|
5
|
-
s.email = "
|
5
|
+
s.email = "reinh@reinh.com"
|
6
6
|
|
7
7
|
s.summary = "A Ruby StatsD client"
|
8
8
|
s.description = "A Ruby StatsD client (https://github.com/etsy/statsd)"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsd-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rein Henrichs
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
type: :development
|
79
79
|
version_requirements: *id004
|
80
80
|
description: A Ruby StatsD client (https://github.com/etsy/statsd)
|
81
|
-
email:
|
81
|
+
email: reinh@reinh.com
|
82
82
|
executables: []
|
83
83
|
|
84
84
|
extensions: []
|