fozzie 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.md +27 -14
- data/Rakefile +7 -1
- data/fozzie.gemspec +0 -2
- data/lib/fozzie/sniff.rb +9 -5
- data/lib/fozzie/version.rb +1 -1
- data/spec/lib/fozzie/configuration_spec.rb +4 -4
- data/spec/lib/fozzie/sniff_spec.rb +39 -15
- data/spec/spec_helper.rb +3 -0
- metadata +5 -36
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
# Fozzie
|
1
|
+
# Fozzie [![travis-ci](https://secure.travis-ci.org/lonelyplanet/fozzie.png)](https://secure.travis-ci.org/lonelyplanet/fozzie)
|
2
2
|
|
3
|
-
Ruby gem for registering statistics to Statsd in various ways.
|
3
|
+
Ruby gem for registering statistics to a [Statsd](https://github.com/etsy/statsd) server in various ways.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
* A Statsd server
|
8
|
+
* Ruby 1.9
|
4
9
|
|
5
10
|
## Basic Usage
|
6
11
|
|
@@ -8,8 +13,9 @@ Send through statistics depending on the type you want to provide:
|
|
8
13
|
|
9
14
|
### Increment counter
|
10
15
|
|
11
|
-
Stats.increment 'wat'
|
12
|
-
|
16
|
+
Stats.increment 'wat' # increments the value in a Statsd bucket called 'some.prefix.wat' -
|
17
|
+
# the exact bucket name depends on the bucket name prefix (see below)
|
18
|
+
|
13
19
|
### Decrement counter
|
14
20
|
|
15
21
|
Stats.decrement 'wat'
|
@@ -142,21 +148,26 @@ To time and register the controller actions within your Rails application, Fozzi
|
|
142
148
|
|
143
149
|
### Rails
|
144
150
|
|
145
|
-
Based on the Rack middleware above, but is more involved in
|
151
|
+
Based on the Rack middleware above, but is more involved in its construction of the bucket value.
|
146
152
|
|
147
153
|
Fozzie::Rails::Middleware will automatically be invoked on Rails initialization.
|
148
154
|
|
149
155
|
## Bucket name prefixes
|
150
156
|
|
151
|
-
Fozzie
|
157
|
+
Fozzie automatically constructs bucket name prefixes from app name,
|
158
|
+
hostname, and environment. For example:
|
152
159
|
|
153
|
-
Stats.increment '
|
160
|
+
Stats.increment 'wat'
|
161
|
+
|
162
|
+
increments the bucket named
|
154
163
|
|
155
|
-
|
164
|
+
app-name.your-computer-name.development.wat
|
156
165
|
|
157
|
-
|
166
|
+
When working on your development machine. This allows multiple
|
167
|
+
application instances, in different environments, to be distinguished
|
168
|
+
easily and collated in Graphite quickly.
|
158
169
|
|
159
|
-
|
170
|
+
The app name can be configured via the YAML configuration.
|
160
171
|
|
161
172
|
## Low level behaviour
|
162
173
|
|
@@ -178,16 +189,18 @@ If you also require UI metrics, you can also include the Mill script in the bott
|
|
178
189
|
|
179
190
|
## Credits
|
180
191
|
|
181
|
-
Currently supported and maintained by [Marc Watts](marc.watts@lonelyplanet.co.uk) @Lonely Planet Online.
|
192
|
+
Currently supported and maintained by [Marc Watts](marc.watts@lonelyplanet.co.uk) @ Lonely Planet Online.
|
182
193
|
|
183
|
-
Big thanks
|
194
|
+
Big thanks and Credits:
|
184
195
|
|
185
196
|
* [Mark Barger](mark.barger@lonelyplanet.co.uk) for support in trying to make this Gem useful.
|
186
197
|
|
187
|
-
* [
|
198
|
+
* [Dave Nolan](https://github.com/textgoeshere)
|
199
|
+
|
200
|
+
* [Etsy](http://codeascraft.etsy.com/) whose [Statsd](https://github.com/etsy/statsd) product has enabled us to come such a long way in a very short period of time. We love Etsy.
|
188
201
|
|
189
202
|
* [reinh](https://github.com/reinh/statsd) for his [statsd](https://github.com/reinh/statsd) Gem.
|
190
203
|
|
191
204
|
## Comments and Feedback
|
192
205
|
|
193
|
-
Please [contact](marc.watts@lonelyplanet.co.uk) me on anything... improvements will be needed and are welcomed greatly.
|
206
|
+
Please [contact](marc.watts@lonelyplanet.co.uk) me on anything... improvements will be needed and are welcomed greatly.
|
data/Rakefile
CHANGED
data/fozzie.gemspec
CHANGED
@@ -35,8 +35,6 @@ Gem::Specification.new do |s|
|
|
35
35
|
|
36
36
|
s.add_development_dependency 'guard'
|
37
37
|
s.add_development_dependency 'guard-rspec'
|
38
|
-
s.add_development_dependency 'guard-rocco'
|
39
|
-
s.add_development_dependency 'fl-rocco'
|
40
38
|
|
41
39
|
s.add_development_dependency 'ruby_gntp'
|
42
40
|
end
|
data/lib/fozzie/sniff.rb
CHANGED
@@ -31,8 +31,10 @@ module Fozzie
|
|
31
31
|
|
32
32
|
def method_added(target)
|
33
33
|
_monitor_meth(target) do |with, without, feature, bin|
|
34
|
-
define_method(with) do |*args|
|
35
|
-
S.time_for(bin)
|
34
|
+
define_method(with) do |*args, &blk|
|
35
|
+
S.time_for(bin) do
|
36
|
+
args.empty? ? self.send(without, &blk) : self.send(without, *args, &blk)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
self.alias_method_chain(target, feature)
|
38
40
|
end
|
@@ -40,8 +42,10 @@ module Fozzie
|
|
40
42
|
|
41
43
|
def singleton_method_added(target)
|
42
44
|
_monitor_meth(target) do |with, without, feature, bin|
|
43
|
-
define_singleton_method(with) do |*args|
|
44
|
-
S.time_for(bin)
|
45
|
+
define_singleton_method(with) do |*args, &blk|
|
46
|
+
S.time_for(bin) do
|
47
|
+
args.empty? ? send(without, &blk) : send(without, *args, &blk)
|
48
|
+
end
|
45
49
|
end
|
46
50
|
self.singleton_class.class_eval { alias_method_chain target, feature }
|
47
51
|
end
|
@@ -50,4 +54,4 @@ module Fozzie
|
|
50
54
|
end
|
51
55
|
|
52
56
|
end
|
53
|
-
end
|
57
|
+
end
|
data/lib/fozzie/version.rb
CHANGED
@@ -21,24 +21,24 @@ describe Fozzie::Configuration do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "defaults env" do
|
24
|
-
subject.env.should eq '
|
24
|
+
subject.env.should eq 'test'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "creates a data prefix" do
|
28
28
|
subject.stubs(:origin_name).returns("")
|
29
|
-
subject.data_prefix.should eq '
|
29
|
+
subject.data_prefix.should eq 'test'
|
30
30
|
end
|
31
31
|
|
32
32
|
it "creates a data prefix with appname when set" do
|
33
33
|
subject.stubs(:origin_name).returns("")
|
34
34
|
subject.appname = 'astoria'
|
35
|
-
subject.data_prefix.should eq 'astoria.
|
35
|
+
subject.data_prefix.should eq 'astoria.test'
|
36
36
|
end
|
37
37
|
|
38
38
|
it "creates a prefix with origin" do
|
39
39
|
subject.stubs(:origin_name).returns("app.server.local")
|
40
40
|
subject.appname = 'astoria'
|
41
|
-
subject.data_prefix.should eq 'astoria.app-server-local.
|
41
|
+
subject.data_prefix.should eq 'astoria.app-server-local.test'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "handles missing configuration namespace" do
|
@@ -2,8 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'fozzie/sniff'
|
3
3
|
|
4
4
|
describe Fozzie::Sniff do
|
5
|
-
|
6
|
-
subject do
|
5
|
+
let(:klass) do
|
7
6
|
class FooBar
|
8
7
|
|
9
8
|
_monitor
|
@@ -22,13 +21,24 @@ describe Fozzie::Sniff do
|
|
22
21
|
|
23
22
|
def honeybadger; :dontcare end
|
24
23
|
|
25
|
-
|
24
|
+
_monitor
|
25
|
+
def method_yielding_to_block
|
26
|
+
yield(:retval_from_block) if block_given?
|
27
|
+
end
|
26
28
|
|
27
|
-
|
29
|
+
_monitor
|
30
|
+
def self.class_method_yielding_to_block
|
31
|
+
yield(:retval_from_block) if block_given?
|
32
|
+
end
|
33
|
+
|
34
|
+
self
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
|
-
context "environments" do
|
31
38
|
|
39
|
+
context "environments" do
|
40
|
+
subject { klass }
|
41
|
+
|
32
42
|
it "is disabled in test" do
|
33
43
|
Fozzie.c.stubs(:env).returns('test')
|
34
44
|
S.expects(:time_for).with(['foo_bar', 'bar!']).never
|
@@ -46,10 +56,10 @@ describe Fozzie::Sniff do
|
|
46
56
|
end
|
47
57
|
|
48
58
|
context 'class methods' do
|
49
|
-
|
50
|
-
|
59
|
+
subject { klass }
|
60
|
+
|
51
61
|
it "aliases methods for monitoring" do
|
52
|
-
subject.methods.grep(/bar/).should
|
62
|
+
subject.methods.grep(/bar/).should =~ [:bar!, :"bar_with_monitor!", :"bar_without_monitor!"]
|
53
63
|
end
|
54
64
|
|
55
65
|
it "behaves like original" do
|
@@ -73,35 +83,49 @@ describe Fozzie::Sniff do
|
|
73
83
|
subject.badger.should eq :cares
|
74
84
|
end
|
75
85
|
|
86
|
+
|
87
|
+
it "yields to a block when given" do
|
88
|
+
subject.class_method_yielding_to_block do |value_from_block|
|
89
|
+
value_from_block
|
90
|
+
end.should eq :retval_from_block
|
91
|
+
end
|
92
|
+
|
76
93
|
end
|
77
94
|
|
78
95
|
context 'instance methods' do
|
79
|
-
|
96
|
+
subject { FooBar.new }
|
97
|
+
|
80
98
|
it "aliases methods for monitoring" do
|
81
|
-
subject.
|
99
|
+
subject.methods.grep(/foo/).should =~ [:foo, :foo_with_monitor, :foo_without_monitor]
|
82
100
|
end
|
83
101
|
|
84
102
|
it "behaves like original" do
|
85
|
-
subject.
|
103
|
+
subject.foo.should eq :foo
|
86
104
|
end
|
87
105
|
|
88
106
|
it "utilises Fozzie" do
|
89
107
|
S.expects(:time_for).with(['foo_bar', 'foo'])
|
90
108
|
|
91
|
-
subject.
|
109
|
+
subject.foo
|
92
110
|
end
|
93
111
|
|
94
112
|
it "handles arguments" do
|
95
113
|
a = [:slow, :slower, :slowest]
|
96
|
-
subject.
|
114
|
+
subject.sloth(*a).should eq a
|
97
115
|
end
|
98
116
|
|
99
117
|
it "does not monitor when mapped" do
|
100
118
|
S.expects(:time_for).with(['foo_bar', 'honeybadger']).never
|
101
119
|
|
102
|
-
subject.
|
120
|
+
subject.honeybadger.should eq :dontcare
|
121
|
+
end
|
122
|
+
|
123
|
+
it "yields to a block when given" do
|
124
|
+
subject.method_yielding_to_block do |value_from_block|
|
125
|
+
value_from_block
|
126
|
+
end.should eq :retval_from_block
|
103
127
|
end
|
104
128
|
|
105
129
|
end
|
106
130
|
|
107
|
-
end
|
131
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
ENV['RACK_ENV'] ||= 'test'
|
2
|
+
|
1
3
|
root = File.expand_path('../', File.dirname(__FILE__))
|
2
4
|
lib = File.expand_path('lib', root)
|
3
5
|
$:.unshift(root, lib)
|
@@ -10,6 +12,7 @@ RSpec.configure do |config|
|
|
10
12
|
end
|
11
13
|
|
12
14
|
require 'fozzie'
|
15
|
+
|
13
16
|
Fozzie.configure do |config|
|
14
17
|
config.host = '127.0.0.1'
|
15
18
|
config.port = 8809
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fozzie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sys-uname
|
@@ -204,38 +204,6 @@ dependencies:
|
|
204
204
|
- - ! '>='
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: '0'
|
207
|
-
- !ruby/object:Gem::Dependency
|
208
|
-
name: guard-rocco
|
209
|
-
requirement: !ruby/object:Gem::Requirement
|
210
|
-
none: false
|
211
|
-
requirements:
|
212
|
-
- - ! '>='
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version: '0'
|
215
|
-
type: :development
|
216
|
-
prerelease: false
|
217
|
-
version_requirements: !ruby/object:Gem::Requirement
|
218
|
-
none: false
|
219
|
-
requirements:
|
220
|
-
- - ! '>='
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: fl-rocco
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
none: false
|
227
|
-
requirements:
|
228
|
-
- - ! '>='
|
229
|
-
- !ruby/object:Gem::Version
|
230
|
-
version: '0'
|
231
|
-
type: :development
|
232
|
-
prerelease: false
|
233
|
-
version_requirements: !ruby/object:Gem::Requirement
|
234
|
-
none: false
|
235
|
-
requirements:
|
236
|
-
- - ! '>='
|
237
|
-
- !ruby/object:Gem::Version
|
238
|
-
version: '0'
|
239
207
|
- !ruby/object:Gem::Dependency
|
240
208
|
name: ruby_gntp
|
241
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,6 +231,7 @@ extra_rdoc_files: []
|
|
263
231
|
files:
|
264
232
|
- .gitignore
|
265
233
|
- .rvmrc
|
234
|
+
- .travis.yml
|
266
235
|
- Gemfile
|
267
236
|
- Guardfile
|
268
237
|
- README.md
|
@@ -309,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
278
|
version: '0'
|
310
279
|
segments:
|
311
280
|
- 0
|
312
|
-
hash:
|
281
|
+
hash: 1130845935272544581
|
313
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
283
|
none: false
|
315
284
|
requirements:
|
@@ -318,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
318
287
|
version: '0'
|
319
288
|
segments:
|
320
289
|
- 0
|
321
|
-
hash:
|
290
|
+
hash: 1130845935272544581
|
322
291
|
requirements: []
|
323
292
|
rubyforge_project: fozzie
|
324
293
|
rubygems_version: 1.8.24
|