rack-graphite 1.1.0 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dd26f2ff86b90d349544fd717a87bcf5f9131f5
4
- data.tar.gz: 57d80d9c81e4e44c0fbafb9167a5fbe7dba341e2
3
+ metadata.gz: 2ee3b228c46d4e023d898ca8240bcd0bccde1782
4
+ data.tar.gz: 13326a994a12e4a8ae0d2274d182c82343928807
5
5
  SHA512:
6
- metadata.gz: 30ab3c0e5af737e6924f7826969d460f444207c2ae360197659867424d813bb6f4cf3a570f116084f56b6ee4d4b5b9b4b2f37c5731f4c3350abe6840c2cbeddc
7
- data.tar.gz: 56895e1ce3137028953dada3d30aacbaa4a4e0f015ffb5d33800bfa28224c8eb236e2e0fd5a619a3bab8a9e75e3943973d794f0e99a3344a42f6f21817eb537b
6
+ metadata.gz: 4c4ecafcee5fb8966f595dbf48b17858defb04f2bd5a95699cf0bf5dd2a0dfb9629b9c82bf84d5e7ade83ea5d45733a3e52c7fd132ab0b8b3e0ddc3e372a341e
7
+ data.tar.gz: 2de42823be00cecbc9cc038b06b8e68e4fe797f5b99526d96c2203aaa494b289b1c1eb858c2f83be54bd9de29e78e3c48dad9b27b0b2336b3e41abf2a8a54217
@@ -18,11 +18,12 @@ module Rack
18
18
  method = env['REQUEST_METHOD'] || 'GET'
19
19
  metric = path_to_graphite(method, path)
20
20
 
21
- result = nil
21
+ status, headers, body = nil
22
22
  Statsd.instance.timing(metric) do
23
- result = @app.call(env)
23
+ status, headers, body = @app.call(env)
24
24
  end
25
- return result
25
+ Statsd.instance.increment("#{metric}.response.#{status}")
26
+ return status, headers, body
26
27
  end
27
28
 
28
29
  def path_to_graphite(method, path)
@@ -1,6 +1,6 @@
1
1
  module Rack
2
2
  class Graphite
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
6
6
 
@@ -77,11 +77,15 @@ describe Rack::Graphite do
77
77
 
78
78
  context 'with a fake app' do
79
79
  let(:app) { double('Mock Rack App') }
80
+ let(:status) { 200 }
81
+ let(:headers) { {:foo => 'bar' } }
82
+ let(:response) { double('Mock Response') }
80
83
  subject(:middleware) { described_class.new(app) }
81
84
 
82
85
  before :each do
83
86
  # Stub out timing by default to and just yield
84
87
  statsd.stub(:timing).and_yield
88
+ statsd.stub(:increment)
85
89
  end
86
90
 
87
91
  describe '#call' do
@@ -89,7 +93,7 @@ describe Rack::Graphite do
89
93
 
90
94
  before :each do
91
95
  # Stub out by default for all tests
92
- app.stub(:call)
96
+ app.stub(:call).and_return([status, headers, response])
93
97
  end
94
98
 
95
99
  it 'should propogate the invocation to the app' do
@@ -97,10 +101,11 @@ describe Rack::Graphite do
97
101
  middleware.call(env)
98
102
  end
99
103
 
104
+ it 'should return response of the app' do
105
+ end
106
+
100
107
  it 'should return the result of the propogated app.call' do
101
- result = double('Mock Rack Response')
102
- app.should_receive(:call).and_return(result)
103
- expect(middleware.call({})).to eql(result)
108
+ expect(middleware.call(env)).to eql([status, headers, response])
104
109
  end
105
110
 
106
111
  it 'should invoke a timer' do
@@ -118,6 +123,7 @@ describe Rack::Graphite do
118
123
  context 'with a root request' do
119
124
  before :each do
120
125
  statsd.should_receive(:timing).with('requests.get.root').and_yield
126
+ statsd.should_receive(:increment).with('requests.get.root.response.200')
121
127
  get '/'
122
128
  end
123
129
  its(:status) { should eql(200) }
@@ -126,6 +132,7 @@ describe Rack::Graphite do
126
132
  context 'with a request with query params' do
127
133
  before :each do
128
134
  statsd.should_receive(:timing).with('requests.get.onelevel').and_yield
135
+ statsd.should_receive(:increment).with('requests.get.onelevel.response.200')
129
136
  get '/onelevel?q=foo'
130
137
  end
131
138
  its(:status) { should eql(200) }
@@ -134,6 +141,7 @@ describe Rack::Graphite do
134
141
  context 'with a PUT request' do
135
142
  before :each do
136
143
  statsd.should_receive(:timing).with('requests.put.onelevel').and_yield
144
+ statsd.should_receive(:increment).with('requests.put.onelevel.response.200')
137
145
  put '/onelevel'
138
146
  end
139
147
  its(:status) { should eql(200) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Tyler Croy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-10-13 00:00:00 Z
12
+ date: 2014-10-27 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler