rt-watchman 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/watchman.rb +9 -3
- data/lib/watchman/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bac90f85de8c5c8965929b5437690acca82046a
|
4
|
+
data.tar.gz: b1078845f612cba2dcd31035e85a22dd5b52cdba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbb99b527956fdac75affe4e32c611f111c12187a04ea8bdbf3a2eb540a72011e389178776e5fa14ad40ea5f5dada2b9792a1015ae5c928c3b922da5773918f1
|
7
|
+
data.tar.gz: 5f5ab2085d32b0a6bb44e1876cf03510d01ff29378f9307375ca3cd2e20b75e27a002ac934fce91641ef2a4e316c35d0bc2353b0f9074de57ca6f4ab49f31e6e
|
data/README.md
CHANGED
@@ -33,6 +33,12 @@ Watchman.benchmark("time.to.wake.up") do
|
|
33
33
|
end
|
34
34
|
```
|
35
35
|
|
36
|
+
To submit a time value in miliseconds:
|
37
|
+
|
38
|
+
``` ruby
|
39
|
+
Watchman.submit("number.of.kittens", 30, :timing)
|
40
|
+
```
|
41
|
+
|
36
42
|
## Global metric prefix
|
37
43
|
|
38
44
|
If you want to prepend all the metric names with a prefix, do the following:
|
data/lib/watchman.rb
CHANGED
@@ -3,13 +3,19 @@ require "benchmark"
|
|
3
3
|
require "statsd"
|
4
4
|
|
5
5
|
class Watchman
|
6
|
+
class SubmitTypeError < RuntimeError; end
|
7
|
+
|
6
8
|
class << self
|
7
9
|
attr_accessor :prefix
|
8
10
|
attr_accessor :host
|
9
11
|
attr_accessor :port
|
10
12
|
|
11
|
-
def submit(name, value)
|
12
|
-
|
13
|
+
def submit(name, value, type = :gauge)
|
14
|
+
case type
|
15
|
+
when :gauge then statsd_client.gauge(metric_name_with_prefix(name), value)
|
16
|
+
when :timing then statsd_client.timing(metric_name_with_prefix(name), value)
|
17
|
+
else raise SubmitTypeError.new("Submit type '#{type}' is not recognized")
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def benchmark(name)
|
@@ -19,7 +25,7 @@ class Watchman
|
|
19
25
|
result = yield
|
20
26
|
end
|
21
27
|
|
22
|
-
|
28
|
+
submit(name, (time.real * 1000).floor, :timing)
|
23
29
|
|
24
30
|
result
|
25
31
|
end
|
data/lib/watchman/version.rb
CHANGED