rt-watchman 0.3.0 → 0.4.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 -1
- data/lib/watchman/version.rb +2 -2
- data/lib/watchman.rb +26 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911f5e3a23afc42f9e7f39ae8ea0d54181206700
|
4
|
+
data.tar.gz: 7656f3dbf1618cfe810fca2630a4228ebdbcf73b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b45c9cd9d3d6c87a7682bd2822281c46aa09f91612eba7e67472939d7ddfb3588200490571b9419057e96a1aee79944969cc07acda6263d4f741b97faf80cc
|
7
|
+
data.tar.gz: 8fade8bba5f753bc430c5e7089531ec3f12ccb87a87023aa989911c9705e5aaf264937cee0cf58c0aab6d1099a01f8174e327456142e4e109151d7ff57496fa7
|
data/README.md
CHANGED
data/lib/watchman/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.
|
1
|
+
class Watchman
|
2
|
+
VERSION = "0.4.0"
|
3
3
|
end
|
data/lib/watchman.rb
CHANGED
@@ -2,38 +2,40 @@ require "watchman/version"
|
|
2
2
|
require "benchmark"
|
3
3
|
require "statsd"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
class Watchman
|
6
|
+
class << self
|
7
|
+
attr_accessor :prefix
|
8
|
+
attr_accessor :host
|
9
|
+
attr_accessor :port
|
10
|
+
|
11
|
+
def submit(name, value)
|
12
|
+
statsd_client.gauge(metric_name_with_prefix(name), value)
|
13
|
+
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
+
def benchmark(name)
|
16
|
+
result = nil
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
time = Benchmark.measure do
|
19
|
+
result = yield
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
result = nil
|
22
|
+
statsd_client.timing(metric_name_with_prefix(name), (time.real * 1000).floor)
|
22
23
|
|
23
|
-
|
24
|
-
result = yield
|
24
|
+
result
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
private
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
def statsd_client
|
30
|
+
@client ||= Statsd.new(@host, @port)
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def metric_name_with_prefix(name)
|
34
|
+
if @prefix
|
35
|
+
"#{@prefix}.#{name}"
|
36
|
+
else
|
37
|
+
name
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rt-watchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rendered Text
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: statsd-ruby
|