statsd-client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +3 -1
- data/lib/statsd.rb +9 -4
- data/test/statsd_test.rb +10 -2
- metadata +38 -59
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
statsd-client (0.0.
|
4
|
+
statsd-client (0.0.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
9
|
mocha (0.9.12)
|
10
|
+
rake (0.9.2)
|
10
11
|
shoulda-context (1.0.0.beta1)
|
11
12
|
|
12
13
|
PLATFORMS
|
@@ -14,5 +15,6 @@ PLATFORMS
|
|
14
15
|
|
15
16
|
DEPENDENCIES
|
16
17
|
mocha
|
18
|
+
rake
|
17
19
|
shoulda-context
|
18
20
|
statsd-client!
|
data/lib/statsd.rb
CHANGED
@@ -3,7 +3,7 @@ require 'resolv'
|
|
3
3
|
|
4
4
|
class Statsd
|
5
5
|
|
6
|
-
Version = '0.0.
|
6
|
+
Version = '0.0.5'
|
7
7
|
|
8
8
|
class << self
|
9
9
|
|
@@ -20,8 +20,13 @@ class Statsd
|
|
20
20
|
|
21
21
|
# +stat+ to log timing for
|
22
22
|
# +time+ is the time to log in ms
|
23
|
-
def timing(stat, time, sample_rate = 1)
|
24
|
-
|
23
|
+
def timing(stat, time = nil, sample_rate = 1)
|
24
|
+
if block_given?
|
25
|
+
start_time = Time.now.to_f
|
26
|
+
yield
|
27
|
+
time = ((Time.now.to_f - start_time) * 1000).floor
|
28
|
+
end
|
29
|
+
send_stats("#{stat}:#{time}|ms", sample_rate)
|
25
30
|
end
|
26
31
|
|
27
32
|
# +stats+ can be a string or an array of strings
|
@@ -74,4 +79,4 @@ class Statsd
|
|
74
79
|
|
75
80
|
end
|
76
81
|
|
77
|
-
end
|
82
|
+
end
|
data/test/statsd_test.rb
CHANGED
@@ -26,6 +26,13 @@ class StatsdTest < Test::Unit::TestCase
|
|
26
26
|
expect_nothing
|
27
27
|
Statsd.timing('test.stat', 23, 0.1)
|
28
28
|
end
|
29
|
+
|
30
|
+
should "work with a block" do
|
31
|
+
expected_send(/^test.stat:2[234]\|ms$/)
|
32
|
+
Statsd.timing('test.stat') do
|
33
|
+
sleep 0.023
|
34
|
+
end
|
35
|
+
end
|
29
36
|
|
30
37
|
end
|
31
38
|
|
@@ -110,7 +117,8 @@ class StatsdTest < Test::Unit::TestCase
|
|
110
117
|
end
|
111
118
|
|
112
119
|
def expected_send(buf)
|
113
|
-
|
120
|
+
buf_re = Regexp.new(buf)
|
121
|
+
UDPSocket.any_instance.expects(:send).with(regexp_matches(buf_re), 0, Statsd.host_ip_addr, Statsd.port).once
|
114
122
|
end
|
115
123
|
|
116
124
|
def expect_nothing
|
@@ -121,4 +129,4 @@ class StatsdTest < Test::Unit::TestCase
|
|
121
129
|
['::1', '127.0.0.1'].include?(ip)
|
122
130
|
end
|
123
131
|
|
124
|
-
end
|
132
|
+
end
|
metadata
CHANGED
@@ -1,58 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsd-client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Ben VandenBos
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-25 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: shoulda-context
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2170356280 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: mocha
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: *2170356280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mocha
|
27
|
+
requirement: &2170355440 !ruby/object:Gem::Requirement
|
37
28
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
44
33
|
type: :development
|
45
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2170355440
|
46
36
|
description: Ruby client for statsd.
|
47
|
-
email:
|
37
|
+
email:
|
48
38
|
- bvandenbos@gmail.com
|
49
39
|
executables: []
|
50
|
-
|
51
40
|
extensions: []
|
52
|
-
|
53
41
|
extra_rdoc_files: []
|
54
|
-
|
55
|
-
files:
|
42
|
+
files:
|
56
43
|
- .gitignore
|
57
44
|
- Gemfile
|
58
45
|
- Gemfile.lock
|
@@ -62,39 +49,31 @@ files:
|
|
62
49
|
- statsd-client.gemspec
|
63
50
|
- test/statsd_test.rb
|
64
51
|
- test/test_helper.rb
|
65
|
-
has_rdoc: true
|
66
52
|
homepage: http://github.com/bvandenbos/statsd-client
|
67
53
|
licenses: []
|
68
|
-
|
69
54
|
post_install_message:
|
70
55
|
rdoc_options: []
|
71
|
-
|
72
|
-
require_paths:
|
56
|
+
require_paths:
|
73
57
|
- lib
|
74
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
59
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
80
65
|
- 0
|
81
|
-
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
hash: 541237035708440788
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
68
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
segments:
|
88
|
-
- 1
|
89
|
-
- 3
|
90
|
-
- 6
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
91
72
|
version: 1.3.6
|
92
73
|
requirements: []
|
93
|
-
|
94
74
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.8.5
|
96
76
|
signing_key:
|
97
77
|
specification_version: 3
|
98
78
|
summary: Ruby client for statsd.
|
99
79
|
test_files: []
|
100
|
-
|