statsd-rack 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/lib/statsd-rack/rack.rb +7 -1
- data/lib/statsd-rack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 175f3e93466438e1dea7ac4c472402c161bcd8bd
|
4
|
+
data.tar.gz: e0b4b56260cc7318f7a3bea294bdd483d8186ba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c6d3ac45f7de019900cb9c2fc927174b8a6f6a949492fe4ecf208095c7a88d98811aee91129bc1d75f1b51c47a0b8e8a6d0bc7961533f33b18beb5f10af54a
|
7
|
+
data.tar.gz: 373f0c0ef7b02376ef5b5e42bdb58f0b5a0dc9064d34fb297b7f1db6e669e1f895f4813c4d5ec070b813254a53bfef4d8792d4aff8ce9414bb7953259ead5114
|
data/README.md
CHANGED
@@ -28,6 +28,18 @@ Edit your app.rb file
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
```
|
31
|
+
(Optional) If you set the `env['API']` parameter inside your application, the time taken and the counter for the API will be tracked
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
YourApp::App.controllers :yourcontroller do
|
35
|
+
get :index do
|
36
|
+
env['API'] = "getStuff"
|
37
|
+
...
|
38
|
+
end
|
39
|
+
...
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
31
43
|
## Usage - Rails
|
32
44
|
|
33
45
|
Edit your config/application.rb file:
|
@@ -41,6 +53,18 @@ Edit your config/application.rb file:
|
|
41
53
|
end
|
42
54
|
```
|
43
55
|
|
56
|
+
(Optional) If you set the `env['API']` parameter inside your application, the time taken and the counter for the API will be tracked
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
YourController < ApplicationController
|
60
|
+
def index
|
61
|
+
request.env['API'] = "getStuff"
|
62
|
+
...
|
63
|
+
end
|
64
|
+
...
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
44
68
|
## Contributing
|
45
69
|
|
46
70
|
1. Fork it
|
data/lib/statsd-rack/rack.rb
CHANGED
@@ -25,7 +25,6 @@ module StatsdRack
|
|
25
25
|
def record_request(status, env)
|
26
26
|
now = Time.now
|
27
27
|
diff = (now - @start)
|
28
|
-
|
29
28
|
if $statsd
|
30
29
|
$statsd.timing("response_time", diff * 1000)
|
31
30
|
if VALID_METHODS.include?(env[REQUEST_METHOD])
|
@@ -36,6 +35,13 @@ module StatsdRack
|
|
36
35
|
if suffix = status_suffix(status)
|
37
36
|
$statsd.increment "status_code.#{status_suffix(status)}"
|
38
37
|
end
|
38
|
+
|
39
|
+
api = env["API"]
|
40
|
+
if api
|
41
|
+
$statsd.timing("response_time.#{api}", diff * 1000)
|
42
|
+
$statsd.increment "status_code.#{status_suffix(status)}.#{api}"
|
43
|
+
end
|
44
|
+
|
39
45
|
if @track_gc && GC.time > 0
|
40
46
|
$statsd.timing "gc.time", GC.time / 1000
|
41
47
|
$statsd.count "gc.collections", GC.collections
|
data/lib/statsd-rack/version.rb
CHANGED