rt-watchman 0.8.0 → 0.9.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 +1 -18
- data/lib/watchman/version.rb +1 -1
- data/lib/watchman.rb +14 -31
- 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: 2518ea25e48bd1335da7036b1f356abe99707b95
|
4
|
+
data.tar.gz: 8761422a4906f54a9a90a1cb0555d60173036e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910ff071eebce01b84107f71db699907b4a4eb29f680a2f5749143b2320cf8ecd12d6aefde11f00b93be8445839240772e336e26c76529a50120d2a2d93fac3f
|
7
|
+
data.tar.gz: 26f3715758b471d21d25678a49bd9d9d2a680321abcaf2c02b73995876e8c3fbe2314fc8449b0c120675bcfb21a5da19d0cc3e0a3bc1194611435503e55fbc28
|
data/README.md
CHANGED
@@ -36,26 +36,9 @@ end
|
|
36
36
|
To submit a time value in miliseconds:
|
37
37
|
|
38
38
|
``` ruby
|
39
|
-
Watchman.submit("number.of.kittens", 30,
|
39
|
+
Watchman.submit("number.of.kittens", 30, :timing)
|
40
40
|
```
|
41
41
|
|
42
|
-
## Tags
|
43
|
-
|
44
|
-
If you want to use a variable that changes often, don't use this:
|
45
|
-
|
46
|
-
``` ruby
|
47
|
-
Watchman.submit("user.#{id}", 30)
|
48
|
-
```
|
49
|
-
|
50
|
-
Use tags. A list of tags is an optional last parameter of `:submit`, `:benchmark`,
|
51
|
-
`:increment` and `:decrement` methods.
|
52
|
-
|
53
|
-
``` ruby
|
54
|
-
Watchman.submit("user", 30, tags: ["#{id}"])
|
55
|
-
```
|
56
|
-
|
57
|
-
Tags list is limited to 3 values.
|
58
|
-
|
59
42
|
## Global metric prefix
|
60
43
|
|
61
44
|
If you want to prepend all the metric names with a prefix, do the following:
|
data/lib/watchman/version.rb
CHANGED
data/lib/watchman.rb
CHANGED
@@ -12,11 +12,8 @@ class Watchman
|
|
12
12
|
attr_accessor :port
|
13
13
|
attr_accessor :test_mode
|
14
14
|
|
15
|
-
def submit(name, value,
|
16
|
-
|
17
|
-
tags = args[:tags] || []
|
18
|
-
|
19
|
-
metric = metric_name_with_prefix(name, tags)
|
15
|
+
def submit(name, value, type = :gauge)
|
16
|
+
metric = metric_name_with_prefix(name)
|
20
17
|
|
21
18
|
case type
|
22
19
|
when :gauge then statsd_client.gauge(metric, value)
|
@@ -26,30 +23,24 @@ class Watchman
|
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
|
-
def benchmark(name
|
30
|
-
tags = args[:tags] || []
|
31
|
-
|
26
|
+
def benchmark(name)
|
32
27
|
result = nil
|
33
28
|
|
34
29
|
time = Benchmark.measure do
|
35
30
|
result = yield
|
36
31
|
end
|
37
32
|
|
38
|
-
submit(name, (time.real * 1000).floor,
|
33
|
+
submit(name, (time.real * 1000).floor, :timing)
|
39
34
|
|
40
35
|
result
|
41
36
|
end
|
42
37
|
|
43
|
-
def increment(name
|
44
|
-
|
45
|
-
|
46
|
-
submit(name, 1, type: :count, tags: tags)
|
38
|
+
def increment(name)
|
39
|
+
submit(name, 1, :count)
|
47
40
|
end
|
48
41
|
|
49
|
-
def decrement(name
|
50
|
-
|
51
|
-
|
52
|
-
submit(name, -1, type: :count, tags: tags)
|
42
|
+
def decrement(name)
|
43
|
+
submit(name, -1, :count)
|
53
44
|
end
|
54
45
|
|
55
46
|
private
|
@@ -62,20 +53,12 @@ class Watchman
|
|
62
53
|
end
|
63
54
|
end
|
64
55
|
|
65
|
-
def metric_name_with_prefix(name
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
full_name.join(".")
|
72
|
-
end
|
73
|
-
|
74
|
-
def tags_string(tags)
|
75
|
-
tags
|
76
|
-
.fill("no_tag", tags.length, [3 - tags.length, 0].max)
|
77
|
-
.first(3)
|
78
|
-
.join(".")
|
56
|
+
def metric_name_with_prefix(name)
|
57
|
+
if @prefix
|
58
|
+
"#{@prefix}.#{name}"
|
59
|
+
else
|
60
|
+
name
|
61
|
+
end
|
79
62
|
end
|
80
63
|
end
|
81
64
|
end
|