fozzie 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +5 -5
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -5
- data/Gemfile +3 -3
- data/README.md +288 -276
- data/Rakefile +6 -6
- data/fozzie.gemspec +29 -29
- data/fozzie.yml.example +14 -14
- data/lib/core_ext/hash/symbolize_keys.rb +21 -21
- data/lib/core_ext/module/alias_method_chain.rb +19 -19
- data/lib/core_ext/module/monitor.rb +12 -12
- data/lib/core_ext/string/snakecase.rb +9 -9
- data/lib/fozzie.rb +67 -67
- data/lib/fozzie/adapter/statsd.rb +95 -95
- data/lib/fozzie/bulk_dsl.rb +27 -27
- data/lib/fozzie/configuration.rb +1 -0
- data/lib/fozzie/dsl.rb +18 -18
- data/lib/fozzie/exception.rb +4 -4
- data/lib/fozzie/interface.rb +139 -139
- data/lib/fozzie/rack/middleware.rb +43 -43
- data/lib/fozzie/sniff.rb +49 -49
- data/lib/fozzie/version.rb +3 -3
- data/resources/mill.js.example +26 -26
- data/spec/config/fozzie.yml +5 -5
- data/spec/lib/core_ext/module/monitor_spec.rb +8 -8
- data/spec/lib/fozzie/adapter/statsd_spec.rb +82 -82
- data/spec/lib/fozzie/bulk_dsl_spec.rb +46 -46
- data/spec/lib/fozzie/configuration_spec.rb +125 -125
- data/spec/lib/fozzie/dsl_spec.rb +15 -15
- data/spec/lib/fozzie/rack/middleware_spec.rb +69 -69
- data/spec/lib/fozzie/rack/sinatra_spec.rb +30 -30
- data/spec/lib/fozzie/sniff_spec.rb +131 -131
- data/spec/lib/fozzie/version_spec.rb +9 -9
- data/spec/lib/fozzie_spec.rb +39 -39
- data/spec/shared_examples/fozzie_adapter.rb +7 -7
- data/spec/shared_examples/interface.rb +159 -159
- data/spec/spec_helper.rb +28 -28
- metadata +24 -36
- data/.rvmrc +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2ZmNjIxOWI2N2UyZWNiMTZhYzJiMzk3NjA2NDYxOTc4ZGJjNjM4MA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f6a706877c3f3cb25972e7a703dd4f43dcb2b87
|
4
|
+
data.tar.gz: 7934207e38e7bff3fa862e6193f7a579227f6a42
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YjcwMjVjN2Y5OWY0OTM4NzE4MTRhM2FhNWIzYzc2MWE3ZDExNjFkNjUxNjlk
|
11
|
-
ODZlNzAyYjc2MjY3OGMyYzY5MDgwNGJmNGMwNTVjOWUyYzcyZjA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGVkMDYzODNhYmI0YTkyM2MyYmFiZGRjNGQ5YjMxOTY3MDRjMTM5M2E1NmZm
|
14
|
-
MmFiNDI2NTllYjZiNDNmYWE4Mzk4MDNlNzU5NDIxMDkwY2UyM2EwMTNhYWM4
|
15
|
-
MDJiYTdlMDhhOTFkNjhhOTFhZjdmM2MyN2Y1ZDYzYjgwMWExMDg=
|
6
|
+
metadata.gz: b7f0e0208f540c6c1634a22a5c6d261ff68096195c99ff5c317686720be49e5e65204a2f7259bdb0455dfd7d6ddd814fb4fcc94995bd60eca168d8ba0c9cc203
|
7
|
+
data.tar.gz: 8e9cb0c5e58968702d4aca13ce4580d43507587875ed1c1cd7fecaf824da9ec4957854230059e5274c54cff52e563e8050c0fe3fc3afecf4debe1d39a86f7f3d
|
data/.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
*.gem
|
2
|
-
.bundle
|
3
|
-
Gemfile.lock
|
4
|
-
pkg/*
|
5
|
-
coverage/*
|
1
|
+
*.gem
|
2
|
+
.bundle
|
3
|
+
Gemfile.lock
|
4
|
+
pkg/*
|
5
|
+
coverage/*
|
6
6
|
.DS_Store
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fozzie
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 1.9.2
|
4
|
-
- 1.9.3
|
5
|
-
- jruby-19mode
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- jruby-19mode
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in fozzie.gemspec
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in fozzie.gemspec
|
4
4
|
gemspec
|
data/README.md
CHANGED
@@ -1,276 +1,288 @@
|
|
1
|
-
# Fozzie [![travis-ci](https://secure.travis-ci.org/lonelyplanet/fozzie.png)](https://secure.travis-ci.org/lonelyplanet/fozzie)
|
2
|
-
|
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
|
9
|
-
|
10
|
-
## Basic Usage
|
11
|
-
|
12
|
-
Send through statistics depending on the type you want to provide:
|
13
|
-
|
14
|
-
### Increment counter
|
15
|
-
``` ruby
|
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
|
-
```
|
19
|
-
### Decrement counter
|
20
|
-
``` ruby
|
21
|
-
Stats.decrement 'wat'
|
22
|
-
```
|
23
|
-
### Decrement counter - provide a value as integer
|
24
|
-
``` ruby
|
25
|
-
Stats.count 'wat', 5
|
26
|
-
```
|
27
|
-
### Basic timing - provide a value in milliseconds
|
28
|
-
``` ruby
|
29
|
-
Stats.timing 'wat', 500
|
30
|
-
```
|
31
|
-
### Timings - provide a block to time against (inline and do syntax supported)
|
32
|
-
``` ruby
|
33
|
-
Stats.time 'wat' { sleep 5 }
|
34
|
-
|
35
|
-
Stats.time_to_do 'wat' do
|
36
|
-
sleep 5
|
37
|
-
end
|
38
|
-
|
39
|
-
Stats.time_for 'wat' { sleep 5 }
|
40
|
-
```
|
41
|
-
### Gauges - register arbitrary values
|
42
|
-
``` ruby
|
43
|
-
Stats.gauge 'wat', 99
|
44
|
-
```
|
45
|
-
### Events - register different events
|
46
|
-
|
47
|
-
|
48
|
-
#### Commits
|
49
|
-
``` ruby
|
50
|
-
Stats.commit
|
51
|
-
|
52
|
-
Stats.committed
|
53
|
-
```
|
54
|
-
#### Builds
|
55
|
-
``` ruby
|
56
|
-
Stats.built
|
57
|
-
|
58
|
-
Stats.build
|
59
|
-
```
|
60
|
-
#### Deployments
|
61
|
-
``` ruby
|
62
|
-
Stats.deployed
|
63
|
-
```
|
64
|
-
|
65
|
-
With a custom app:
|
66
|
-
``` ruby
|
67
|
-
Stats.deployed 'watapp'
|
68
|
-
|
69
|
-
Stats.deploy
|
70
|
-
```
|
71
|
-
|
72
|
-
With a custom app:
|
73
|
-
``` ruby
|
74
|
-
Stats.deploy 'watapp'
|
75
|
-
```
|
76
|
-
|
77
|
-
#### Custom
|
78
|
-
``` ruby
|
79
|
-
Stats.event 'pull'
|
80
|
-
```
|
81
|
-
With a custom app:
|
82
|
-
|
83
|
-
``` ruby
|
84
|
-
Stats.event 'pull', 'watapp'
|
85
|
-
```
|
86
|
-
### Boolean result - pass a value to be true or false, and increment on true
|
87
|
-
``` ruby
|
88
|
-
Stats.increment_on 'wat', duck.valid?
|
89
|
-
```
|
90
|
-
## Sampling
|
91
|
-
|
92
|
-
Each of the above methods accepts a sample rate as the last argument (before any applicable blocks), e.g:
|
93
|
-
|
94
|
-
``` ruby
|
95
|
-
Stats.increment 'wat', 10
|
96
|
-
|
97
|
-
Stats.decrement 'wat', 10
|
98
|
-
|
99
|
-
Stats.count 'wat', 5, 10
|
100
|
-
```
|
101
|
-
## Monitor
|
102
|
-
|
103
|
-
You can monitor methods with the following:
|
104
|
-
``` ruby
|
105
|
-
class FooBar
|
106
|
-
|
107
|
-
_monitor
|
108
|
-
def zar
|
109
|
-
# my code here...
|
110
|
-
end
|
111
|
-
|
112
|
-
_monitor("my.awesome.bucket.name")
|
113
|
-
def quux
|
114
|
-
# something
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
```
|
119
|
-
This will register the processing time for this method, everytime it is called, under the Graphite bucket `foo_bar.zar`.
|
120
|
-
|
121
|
-
This will work on both Class and Instance methods.
|
122
|
-
|
123
|
-
## Bulk
|
124
|
-
|
125
|
-
You can send a bulk of metrics using the `bulk` method:
|
126
|
-
``` ruby
|
127
|
-
Stats.bulk do
|
128
|
-
increment 'wat'
|
129
|
-
decrement 'wot'
|
130
|
-
gauge 'foo', rand
|
131
|
-
time_to_do 'wat_timer' { sleep 4 }
|
132
|
-
end
|
133
|
-
```
|
134
|
-
|
135
|
-
This will send all the given metrics in a single packet to the statistics server.
|
136
|
-
|
137
|
-
## Namespaces
|
138
|
-
|
139
|
-
Fozzie supports the following namespaces as default
|
140
|
-
|
141
|
-
``` ruby
|
142
|
-
Stats.increment 'wat'
|
143
|
-
S.increment 'wat'
|
144
|
-
Statistics.increment 'wat'
|
145
|
-
Warehouse.increment 'wat'
|
146
|
-
```
|
147
|
-
|
148
|
-
You can customise this via the YAML configuration (see instructions below)
|
149
|
-
|
150
|
-
## Configuration
|
151
|
-
|
152
|
-
Fozzie is configured via a YAML or by setting a block against the Fozzie namespace.
|
153
|
-
|
154
|
-
### YAML
|
155
|
-
|
156
|
-
Create a `fozzie.yml` within a `config` folder on the root of your app, which contains your settings for each env. Simple, verbose example below.
|
157
|
-
|
158
|
-
``` yaml
|
159
|
-
development:
|
160
|
-
appname: wat
|
161
|
-
host: '127.0.0.1'
|
162
|
-
port: 8125
|
163
|
-
namespaces: %w{Foo Bar Wat}
|
164
|
-
prefix: %{foo bar car}
|
165
|
-
test:
|
166
|
-
appname: wat
|
167
|
-
host: 'localhost'
|
168
|
-
port: 8125
|
169
|
-
namespaces: %w{Foo Bar Wat}
|
170
|
-
production:
|
171
|
-
appname: wat
|
172
|
-
host: 'stats.wat.com'
|
173
|
-
port: 8125
|
174
|
-
namespaces: %w{Foo Bar Wat}
|
175
|
-
```
|
176
|
-
|
177
|
-
### Configure block
|
178
|
-
|
179
|
-
``` ruby
|
180
|
-
Fozzie.configure do |config|
|
181
|
-
config.appname = "wat"
|
182
|
-
config.host = "127.0.0.1"
|
183
|
-
config.port = 8125
|
184
|
-
config.prefix = []
|
185
|
-
end
|
186
|
-
```
|
187
|
-
### Prefixes
|
188
|
-
|
189
|
-
You can inject or set the prefix value for your application.
|
190
|
-
|
191
|
-
``` ruby
|
192
|
-
Fozzie.configure do |config|
|
193
|
-
config.prefix = ['foo', 'wat', 'bar']
|
194
|
-
end
|
195
|
-
```
|
196
|
-
|
197
|
-
``` ruby
|
198
|
-
Fozzie.configure do |config|
|
199
|
-
config.prefix << 'dynamic-value'
|
200
|
-
end
|
201
|
-
```
|
202
|
-
|
203
|
-
Prefixes are cached on first use, therefore any changes to the Fozzie configure prefix after first metric is sent in your application will be ignored.
|
204
|
-
|
205
|
-
## Middleware
|
206
|
-
|
207
|
-
To time and register the controller actions within your Rack and Rails application, Fozzie provides some middleware.
|
208
|
-
|
209
|
-
### Rack
|
210
|
-
|
211
|
-
``` ruby
|
212
|
-
require 'rack'
|
213
|
-
require 'fozzie/rack/middleware'
|
214
|
-
|
215
|
-
app = Rack::Builder.new {
|
216
|
-
use Fozzie::Rack::Middleware
|
217
|
-
lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'OK'] }
|
218
|
-
}
|
219
|
-
```
|
220
|
-
|
221
|
-
### Rails
|
222
|
-
|
223
|
-
See [Fozzie Rails](http://github.com/lonelyplanet/fozzie_rails).
|
224
|
-
|
225
|
-
## Bucket name prefixes
|
226
|
-
|
227
|
-
Fozzie automatically constructs bucket name prefixes from app name,
|
228
|
-
hostname, and environment. For example:
|
229
|
-
|
230
|
-
``` ruby
|
231
|
-
Stats.increment 'wat'
|
232
|
-
```
|
233
|
-
increments the bucket named
|
234
|
-
``` text
|
235
|
-
app-name.your-computer-name.development.wat
|
236
|
-
```
|
237
|
-
|
238
|
-
When working on your development machine. This allows multiple
|
239
|
-
application instances, in different environments, to be distinguished
|
240
|
-
easily and collated in Graphite quickly.
|
241
|
-
|
242
|
-
The app name can be configured via the YAML configuration.
|
243
|
-
|
244
|
-
## Low level behaviour
|
245
|
-
|
246
|
-
The current implementation of Fozzie wraps the sending of the statistic in a timeout and rescue block, which prevent long host lookups (i.e. if your stats server disappears) and minimises impact on your code or application if something is erroring at a low level.
|
247
|
-
|
248
|
-
Fozzie will try to log these errors, but only if a logger has been applied (which by default it does not). Examples:
|
249
|
-
|
250
|
-
``` ruby
|
251
|
-
require 'logger'
|
252
|
-
Fozzie.logger = Logger.new(STDOUT)
|
253
|
-
```
|
254
|
-
|
255
|
-
``` ruby
|
256
|
-
require 'logger'
|
257
|
-
Fozzie.logger = Logger.new 'log/fozzie.log'
|
258
|
-
```
|
259
|
-
|
260
|
-
This may change, depending on feedback and more production experience.
|
261
|
-
|
262
|
-
## Credits
|
263
|
-
|
264
|
-
Currently supported and maintained by [Marc Watts](marc.watts@lonelyplanet.co.uk) @ Lonely Planet Online.
|
265
|
-
|
266
|
-
Big thanks and Credits:
|
267
|
-
|
268
|
-
* [Dave Nolan](https://github.com/textgoeshere)
|
269
|
-
|
270
|
-
* [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.
|
271
|
-
|
272
|
-
* [reinh](https://github.com/reinh/statsd) for his [statsd](https://github.com/reinh/statsd) Gem.
|
273
|
-
|
274
|
-
## Comments and Feedback
|
275
|
-
|
276
|
-
Please [contact](marc.watts@lonelyplanet.co.uk) me on anything... improvements will be needed and are welcomed greatly.
|
1
|
+
# Fozzie [![travis-ci](https://secure.travis-ci.org/lonelyplanet/fozzie.png)](https://secure.travis-ci.org/lonelyplanet/fozzie)
|
2
|
+
|
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
|
9
|
+
|
10
|
+
## Basic Usage
|
11
|
+
|
12
|
+
Send through statistics depending on the type you want to provide:
|
13
|
+
|
14
|
+
### Increment counter
|
15
|
+
``` ruby
|
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
|
+
```
|
19
|
+
### Decrement counter
|
20
|
+
``` ruby
|
21
|
+
Stats.decrement 'wat'
|
22
|
+
```
|
23
|
+
### Decrement counter - provide a value as integer
|
24
|
+
``` ruby
|
25
|
+
Stats.count 'wat', 5
|
26
|
+
```
|
27
|
+
### Basic timing - provide a value in milliseconds
|
28
|
+
``` ruby
|
29
|
+
Stats.timing 'wat', 500
|
30
|
+
```
|
31
|
+
### Timings - provide a block to time against (inline and do syntax supported)
|
32
|
+
``` ruby
|
33
|
+
Stats.time 'wat' { sleep 5 }
|
34
|
+
|
35
|
+
Stats.time_to_do 'wat' do
|
36
|
+
sleep 5
|
37
|
+
end
|
38
|
+
|
39
|
+
Stats.time_for 'wat' { sleep 5 }
|
40
|
+
```
|
41
|
+
### Gauges - register arbitrary values
|
42
|
+
``` ruby
|
43
|
+
Stats.gauge 'wat', 99
|
44
|
+
```
|
45
|
+
### Events - register different events
|
46
|
+
|
47
|
+
|
48
|
+
#### Commits
|
49
|
+
``` ruby
|
50
|
+
Stats.commit
|
51
|
+
|
52
|
+
Stats.committed
|
53
|
+
```
|
54
|
+
#### Builds
|
55
|
+
``` ruby
|
56
|
+
Stats.built
|
57
|
+
|
58
|
+
Stats.build
|
59
|
+
```
|
60
|
+
#### Deployments
|
61
|
+
``` ruby
|
62
|
+
Stats.deployed
|
63
|
+
```
|
64
|
+
|
65
|
+
With a custom app:
|
66
|
+
``` ruby
|
67
|
+
Stats.deployed 'watapp'
|
68
|
+
|
69
|
+
Stats.deploy
|
70
|
+
```
|
71
|
+
|
72
|
+
With a custom app:
|
73
|
+
``` ruby
|
74
|
+
Stats.deploy 'watapp'
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Custom
|
78
|
+
``` ruby
|
79
|
+
Stats.event 'pull'
|
80
|
+
```
|
81
|
+
With a custom app:
|
82
|
+
|
83
|
+
``` ruby
|
84
|
+
Stats.event 'pull', 'watapp'
|
85
|
+
```
|
86
|
+
### Boolean result - pass a value to be true or false, and increment on true
|
87
|
+
``` ruby
|
88
|
+
Stats.increment_on 'wat', duck.valid?
|
89
|
+
```
|
90
|
+
## Sampling
|
91
|
+
|
92
|
+
Each of the above methods accepts a sample rate as the last argument (before any applicable blocks), e.g:
|
93
|
+
|
94
|
+
``` ruby
|
95
|
+
Stats.increment 'wat', 10
|
96
|
+
|
97
|
+
Stats.decrement 'wat', 10
|
98
|
+
|
99
|
+
Stats.count 'wat', 5, 10
|
100
|
+
```
|
101
|
+
## Monitor
|
102
|
+
|
103
|
+
You can monitor methods with the following:
|
104
|
+
``` ruby
|
105
|
+
class FooBar
|
106
|
+
|
107
|
+
_monitor
|
108
|
+
def zar
|
109
|
+
# my code here...
|
110
|
+
end
|
111
|
+
|
112
|
+
_monitor("my.awesome.bucket.name")
|
113
|
+
def quux
|
114
|
+
# something
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
```
|
119
|
+
This will register the processing time for this method, everytime it is called, under the Graphite bucket `foo_bar.zar`.
|
120
|
+
|
121
|
+
This will work on both Class and Instance methods.
|
122
|
+
|
123
|
+
## Bulk
|
124
|
+
|
125
|
+
You can send a bulk of metrics using the `bulk` method:
|
126
|
+
``` ruby
|
127
|
+
Stats.bulk do
|
128
|
+
increment 'wat'
|
129
|
+
decrement 'wot'
|
130
|
+
gauge 'foo', rand
|
131
|
+
time_to_do 'wat_timer' { sleep 4 }
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
This will send all the given metrics in a single packet to the statistics server.
|
136
|
+
|
137
|
+
## Namespaces
|
138
|
+
|
139
|
+
Fozzie supports the following namespaces as default
|
140
|
+
|
141
|
+
``` ruby
|
142
|
+
Stats.increment 'wat'
|
143
|
+
S.increment 'wat'
|
144
|
+
Statistics.increment 'wat'
|
145
|
+
Warehouse.increment 'wat'
|
146
|
+
```
|
147
|
+
|
148
|
+
You can customise this via the YAML configuration (see instructions below)
|
149
|
+
|
150
|
+
## Configuration
|
151
|
+
|
152
|
+
Fozzie is configured via a YAML or by setting a block against the Fozzie namespace.
|
153
|
+
|
154
|
+
### YAML
|
155
|
+
|
156
|
+
Create a `fozzie.yml` within a `config` folder on the root of your app, which contains your settings for each env. Simple, verbose example below.
|
157
|
+
|
158
|
+
``` yaml
|
159
|
+
development:
|
160
|
+
appname: wat
|
161
|
+
host: '127.0.0.1'
|
162
|
+
port: 8125
|
163
|
+
namespaces: %w{Foo Bar Wat}
|
164
|
+
prefix: %{foo bar car}
|
165
|
+
test:
|
166
|
+
appname: wat
|
167
|
+
host: 'localhost'
|
168
|
+
port: 8125
|
169
|
+
namespaces: %w{Foo Bar Wat}
|
170
|
+
production:
|
171
|
+
appname: wat
|
172
|
+
host: 'stats.wat.com'
|
173
|
+
port: 8125
|
174
|
+
namespaces: %w{Foo Bar Wat}
|
175
|
+
```
|
176
|
+
|
177
|
+
### Configure block
|
178
|
+
|
179
|
+
``` ruby
|
180
|
+
Fozzie.configure do |config|
|
181
|
+
config.appname = "wat"
|
182
|
+
config.host = "127.0.0.1"
|
183
|
+
config.port = 8125
|
184
|
+
config.prefix = []
|
185
|
+
end
|
186
|
+
```
|
187
|
+
### Prefixes
|
188
|
+
|
189
|
+
You can inject or set the prefix value for your application.
|
190
|
+
|
191
|
+
``` ruby
|
192
|
+
Fozzie.configure do |config|
|
193
|
+
config.prefix = ['foo', 'wat', 'bar']
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
``` ruby
|
198
|
+
Fozzie.configure do |config|
|
199
|
+
config.prefix << 'dynamic-value'
|
200
|
+
end
|
201
|
+
```
|
202
|
+
|
203
|
+
Prefixes are cached on first use, therefore any changes to the Fozzie configure prefix after first metric is sent in your application will be ignored.
|
204
|
+
|
205
|
+
## Middleware
|
206
|
+
|
207
|
+
To time and register the controller actions within your Rack and Rails application, Fozzie provides some middleware.
|
208
|
+
|
209
|
+
### Rack
|
210
|
+
|
211
|
+
``` ruby
|
212
|
+
require 'rack'
|
213
|
+
require 'fozzie/rack/middleware'
|
214
|
+
|
215
|
+
app = Rack::Builder.new {
|
216
|
+
use Fozzie::Rack::Middleware
|
217
|
+
lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'OK'] }
|
218
|
+
}
|
219
|
+
```
|
220
|
+
|
221
|
+
### Rails
|
222
|
+
|
223
|
+
See [Fozzie Rails](http://github.com/lonelyplanet/fozzie_rails).
|
224
|
+
|
225
|
+
## Bucket name prefixes
|
226
|
+
|
227
|
+
Fozzie automatically constructs bucket name prefixes from app name,
|
228
|
+
hostname, and environment. For example:
|
229
|
+
|
230
|
+
``` ruby
|
231
|
+
Stats.increment 'wat'
|
232
|
+
```
|
233
|
+
increments the bucket named
|
234
|
+
``` text
|
235
|
+
app-name.your-computer-name.development.wat
|
236
|
+
```
|
237
|
+
|
238
|
+
When working on your development machine. This allows multiple
|
239
|
+
application instances, in different environments, to be distinguished
|
240
|
+
easily and collated in Graphite quickly.
|
241
|
+
|
242
|
+
The app name can be configured via the YAML configuration.
|
243
|
+
|
244
|
+
## Low level behaviour
|
245
|
+
|
246
|
+
The current implementation of Fozzie wraps the sending of the statistic in a timeout and rescue block, which prevent long host lookups (i.e. if your stats server disappears) and minimises impact on your code or application if something is erroring at a low level.
|
247
|
+
|
248
|
+
Fozzie will try to log these errors, but only if a logger has been applied (which by default it does not). Examples:
|
249
|
+
|
250
|
+
``` ruby
|
251
|
+
require 'logger'
|
252
|
+
Fozzie.logger = Logger.new(STDOUT)
|
253
|
+
```
|
254
|
+
|
255
|
+
``` ruby
|
256
|
+
require 'logger'
|
257
|
+
Fozzie.logger = Logger.new 'log/fozzie.log'
|
258
|
+
```
|
259
|
+
|
260
|
+
This may change, depending on feedback and more production experience.
|
261
|
+
|
262
|
+
## Credits
|
263
|
+
|
264
|
+
Currently supported and maintained by [Marc Watts](marc.watts@lonelyplanet.co.uk) @ Lonely Planet Online.
|
265
|
+
|
266
|
+
Big thanks and Credits:
|
267
|
+
|
268
|
+
* [Dave Nolan](https://github.com/textgoeshere)
|
269
|
+
|
270
|
+
* [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.
|
271
|
+
|
272
|
+
* [reinh](https://github.com/reinh/statsd) for his [statsd](https://github.com/reinh/statsd) Gem.
|
273
|
+
|
274
|
+
## Comments and Feedback
|
275
|
+
|
276
|
+
Please [contact](marc.watts@lonelyplanet.co.uk) me on anything... improvements will be needed and are welcomed greatly.
|
277
|
+
|
278
|
+
## License
|
279
|
+
|
280
|
+
Copyright 2014 LONELY PLANET PUBLICATIONS LTD
|
281
|
+
|
282
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
283
|
+
You may obtain a copy of the License at
|
284
|
+
|
285
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
286
|
+
|
287
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
288
|
+
See the License for the specific language governing permissions and limitations under the License.
|