statsy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/statsy.rb +2 -2
- data/test/statsy_test.rb +26 -0
- metadata +7 -3
data/lib/statsy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Client to access statsd service authored by etsy. Yay etsy!
|
2
2
|
# https://github.com/etsy/statsd
|
3
3
|
module Statsy
|
4
|
-
VERSION="0.1.
|
4
|
+
VERSION="0.1.3"
|
5
5
|
|
6
6
|
module Transport
|
7
7
|
require 'socket'
|
@@ -102,7 +102,7 @@ module Statsy
|
|
102
102
|
self
|
103
103
|
end
|
104
104
|
|
105
|
-
|
105
|
+
protected
|
106
106
|
def write(stat, value, modifier, sampling)
|
107
107
|
if sampling < 1
|
108
108
|
if Kernel.rand < sampling
|
data/test/statsy_test.rb
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require File.expand_path('../../lib/statsy', __FILE__)
|
3
3
|
|
4
|
+
class SubclassUnit < Test::Unit::TestCase
|
5
|
+
class Frob < Statsy::Client
|
6
|
+
protected
|
7
|
+
def write(stat, value, modifier, sampling)
|
8
|
+
super("frob", value, modifier, sampling)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@transport = Statsy::Transport::Queue.new
|
14
|
+
@client = Frob.new(@transport)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_subclass_should_override_write_with_full_frobbing
|
18
|
+
transport = Statsy::Transport::Queue.new
|
19
|
+
client = Statsy::Client.new()
|
20
|
+
|
21
|
+
@client.increment("foo.stat", 1)
|
22
|
+
@client.measure("foo.mess", 100)
|
23
|
+
|
24
|
+
assert_equal 2, @transport.size
|
25
|
+
assert_equal "frob:1|c", @transport.shift
|
26
|
+
assert_equal "frob:100|ms", @transport.shift
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
4
30
|
class Unit < Test::Unit::TestCase
|
5
31
|
def setup
|
6
32
|
@transport = Statsy::Transport::Queue.new
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Sean Treadway
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-29 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
version: "0"
|
@@ -58,6 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
60
|
requirements:
|
59
61
|
- - ">="
|
60
62
|
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
61
64
|
segments:
|
62
65
|
- 0
|
63
66
|
version: "0"
|
@@ -66,6 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
69
|
requirements:
|
67
70
|
- - ">="
|
68
71
|
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
69
73
|
segments:
|
70
74
|
- 0
|
71
75
|
version: "0"
|