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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29bac7b67fdd0cc7d27b534e74c805a927a56e51
4
- data.tar.gz: b274e6216e6ab549ceb0aa3b0bb9d6f7288f2a6a
3
+ metadata.gz: 175f3e93466438e1dea7ac4c472402c161bcd8bd
4
+ data.tar.gz: e0b4b56260cc7318f7a3bea294bdd483d8186ba4
5
5
  SHA512:
6
- metadata.gz: 11b925b517bfe92cdc7c69e2c293cb5d547016b9f9d98785d605454acf0e5bd13bef91e3cc5d25b26a220e803cbf21fc8cd109f30e954b39abef283d9265e06d
7
- data.tar.gz: c33a89955c6d02a1678a5e7cb2c6172da0a9e3fc17ae634046f85268826fb97bce7f010ab25096843db25dedf80e6abb2e207e2cd90880f5bd8dd8fc61c6cba7
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module StatsdRack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsd-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghuram Sreenath