lookout-statsd 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +6 -6
- data/lib/statsd.rb +2 -7
- data/spec/statsd_spec.rb +19 -5
- data/statsd.gemspec +1 -1
- metadata +10 -10
data/Gemfile
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem "rake"
|
4
4
|
|
5
5
|
group :test do
|
6
6
|
if RUBY_VERSION > "1.9"
|
7
|
-
gem '
|
7
|
+
gem "ruby-debug19", :require => 'ruby-debug'
|
8
8
|
else
|
9
|
-
gem
|
9
|
+
gem "ruby-debug"
|
10
10
|
end
|
11
11
|
|
12
|
-
gem
|
13
|
-
gem
|
12
|
+
gem "rspec"
|
13
|
+
gem "cucumber"
|
14
14
|
end
|
15
15
|
|
16
16
|
gemspec
|
data/lib/statsd.rb
CHANGED
@@ -52,24 +52,19 @@ module Statsd
|
|
52
52
|
|
53
53
|
# +stats+ can be a string or an array of strings
|
54
54
|
def increment(stats, sample_rate = 1)
|
55
|
-
if @prefix
|
56
|
-
stats = "#{@prefix}.#{stats}"
|
57
|
-
end
|
58
55
|
update_counter stats, 1, sample_rate
|
59
56
|
end
|
60
57
|
|
61
58
|
# +stats+ can be a string or an array of strings
|
62
59
|
def decrement(stats, sample_rate = 1)
|
63
|
-
if @prefix
|
64
|
-
stats = "#{@prefix}.#{stats}"
|
65
|
-
end
|
66
60
|
update_counter stats, -1, sample_rate
|
67
61
|
end
|
68
62
|
|
69
63
|
# +stats+ can be a string or array of strings
|
70
64
|
def update_counter(stats, delta = 1, sample_rate = 1)
|
71
65
|
stats = Array(stats)
|
72
|
-
|
66
|
+
p = @prefix ? "#{@prefix}." : '' # apply prefix to each
|
67
|
+
send_stats(stats.map { |s| "#{p}#{s}:#{delta}|c" }, sample_rate)
|
73
68
|
end
|
74
69
|
|
75
70
|
# +stats+ is a hash
|
data/spec/statsd_spec.rb
CHANGED
@@ -93,9 +93,8 @@ describe Statsd::Client do
|
|
93
93
|
describe '#increment' do
|
94
94
|
let(:c) { Statsd::Client.new }
|
95
95
|
|
96
|
-
it 'should
|
97
|
-
c.
|
98
|
-
c.should_receive(:update_counter).with('dev.foo', anything(), anything())
|
96
|
+
it 'should update the counter by 1' do
|
97
|
+
c.should_receive(:update_counter).with('foo', 1, anything())
|
99
98
|
c.increment('foo')
|
100
99
|
end
|
101
100
|
end
|
@@ -103,10 +102,25 @@ describe Statsd::Client do
|
|
103
102
|
describe '#decrement' do
|
104
103
|
let(:c) { Statsd::Client.new }
|
105
104
|
|
105
|
+
it 'should update the counter by -1' do
|
106
|
+
c.should_receive(:update_counter).with('foo', -1, anything())
|
107
|
+
c.decrement('foo')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#update_counter' do
|
112
|
+
let(:c) { Statsd::Client.new }
|
113
|
+
|
106
114
|
it 'should prepend the prefix if it has one' do
|
107
115
|
c.prefix = 'dev'
|
108
|
-
c.should_receive(:
|
109
|
-
c.
|
116
|
+
c.should_receive(:send_stats).with(['dev.foo:123|c'], anything())
|
117
|
+
c.update_counter('foo', 123)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should prepend multiple prefixes if it has one' do
|
121
|
+
c.prefix = 'dev'
|
122
|
+
c.should_receive(:send_stats).with(['dev.foo:123|c', 'dev.bar:123|c'], anything())
|
123
|
+
c.update_counter(['foo', 'bar'], 123)
|
110
124
|
end
|
111
125
|
end
|
112
126
|
|
data/statsd.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookout-statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- R. Tyler Croy
|
@@ -17,9 +17,11 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2013-
|
20
|
+
date: 2013-05-14 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
+
type: :runtime
|
24
|
+
name: eventmachine
|
23
25
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
26
|
none: false
|
25
27
|
requirements:
|
@@ -31,11 +33,11 @@ dependencies:
|
|
31
33
|
- 12
|
32
34
|
- 10
|
33
35
|
version: 0.12.10
|
34
|
-
prerelease: false
|
35
|
-
type: :runtime
|
36
36
|
requirement: *id001
|
37
|
-
|
37
|
+
prerelease: false
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
+
type: :runtime
|
40
|
+
name: erubis
|
39
41
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
42
|
none: false
|
41
43
|
requirements:
|
@@ -47,10 +49,8 @@ dependencies:
|
|
47
49
|
- 6
|
48
50
|
- 6
|
49
51
|
version: 2.6.6
|
50
|
-
prerelease: false
|
51
|
-
type: :runtime
|
52
52
|
requirement: *id002
|
53
|
-
|
53
|
+
prerelease: false
|
54
54
|
description: A network daemon for aggregating statistics (counters and timers), rolling them up, then sending them to graphite.
|
55
55
|
email:
|
56
56
|
- rtyler.croy@mylookout.com
|