saddle 0.0.50 → 0.0.51
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 +8 -8
- data/lib/saddle/middleware/logging/statsd.rb +6 -1
- data/lib/saddle/version.rb +1 -1
- data/spec/middleware/logging/statsd_spec.rb +26 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjAxNjc4ZDBjMjUwZTg1ZTVlNzc1YjI1YTAxZTg0YmU2N2M2YTFkMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGYxYjA4M2VhNDM1ZjI4NzdmZDQ2NmNlMmYwYzAwM2U1NGJlYjczZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDEwZjdjNmIzNzg2ODFiNDlmZjNhM2Y5MjkwMWZhODY3N2ExNDgzYzQzNWI2
|
10
|
+
MTc3MDZhNTJlOTU4MGE1MTc1ZmUyNjc2MTBhMDU0OGQ0YzMyNGQ3MTYzYTU4
|
11
|
+
MTI2NjBiMjc0ZTMxYmE2ZGU3M2E2MDA0MmUzY2U4ODg1ZGU5YzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmE5MWExZmJiNmI1ZjM1YzY1NGQ5MWM4OGZjOTk0NTlhN2ZhMzg3MDU1MzE4
|
14
|
+
NDg4YWNhYzFkMzhjYjkzOTU5YWZiOTEzODhkNjZlMmFhNDYwMGExNTczMTI1
|
15
|
+
Y2VmMzNmYmY5ZGQxZTkxZTA5OGNhZGQ4NmI2NmViZmI5M2RlNzI=
|
@@ -52,13 +52,18 @@ module Saddle
|
|
52
52
|
|
53
53
|
# If we have a path, wrap the call
|
54
54
|
if statsd_path
|
55
|
-
self.statsd.time(statsd_path) do
|
55
|
+
self.statsd.time(sanitize_path(statsd_path)) do
|
56
56
|
@app.call(env)
|
57
57
|
end
|
58
58
|
else
|
59
59
|
@app.call(env)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def sanitize_path(path)
|
65
|
+
path.gsub(/\s+/, '_').gsub(/\//, '-').gsub(/[^a-zA-Z_\-0-9\.]/, '')
|
66
|
+
end
|
62
67
|
end
|
63
68
|
|
64
69
|
end
|
data/lib/saddle/version.rb
CHANGED
@@ -7,13 +7,15 @@ describe Saddle::Middleware::Logging::StatsdLogger do
|
|
7
7
|
|
8
8
|
context "test Statsd middleware" do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
class StatsdClient < Saddle::Client
|
11
|
+
add_middleware({
|
12
|
+
:klass => Saddle::Middleware::Logging::StatsdLogger,
|
13
|
+
:args => ['127.0.0.1'],
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should log a request" do
|
18
|
+
::Statsd.any_instance.should_receive(:time).with("saddle.statsd_client.raw.localhost-test").and_yield
|
17
19
|
|
18
20
|
client = StatsdClient.create(
|
19
21
|
:stubs => Faraday::Adapter::Test::Stubs.new do |stub|
|
@@ -29,5 +31,22 @@ describe Saddle::Middleware::Logging::StatsdLogger do
|
|
29
31
|
client.requester.get('/test').should == 'Party on!'
|
30
32
|
end
|
31
33
|
|
34
|
+
it "should allow overriding the path" do
|
35
|
+
::Statsd.any_instance.should_receive(:time).with("hello").and_yield
|
36
|
+
|
37
|
+
client = StatsdClient.create(
|
38
|
+
:stubs => Faraday::Adapter::Test::Stubs.new do |stub|
|
39
|
+
stub.get('/test') {
|
40
|
+
[
|
41
|
+
200,
|
42
|
+
{},
|
43
|
+
'Party on!',
|
44
|
+
]
|
45
|
+
}
|
46
|
+
end
|
47
|
+
)
|
48
|
+
client.requester.get('/test', {}, {:statsd_path => "hello"}).should == 'Party on!'
|
49
|
+
end
|
50
|
+
|
32
51
|
end
|
33
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.51
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Lewis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|