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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 911f5e3a23afc42f9e7f39ae8ea0d54181206700
4
- data.tar.gz: 7656f3dbf1618cfe810fca2630a4228ebdbcf73b
3
+ metadata.gz: 0bac90f85de8c5c8965929b5437690acca82046a
4
+ data.tar.gz: b1078845f612cba2dcd31035e85a22dd5b52cdba
5
5
  SHA512:
6
- metadata.gz: 06b45c9cd9d3d6c87a7682bd2822281c46aa09f91612eba7e67472939d7ddfb3588200490571b9419057e96a1aee79944969cc07acda6263d4f741b97faf80cc
7
- data.tar.gz: 8fade8bba5f753bc430c5e7089531ec3f12ccb87a87023aa989911c9705e5aaf264937cee0cf58c0aab6d1099a01f8174e327456142e4e109151d7ff57496fa7
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
- statsd_client.gauge(metric_name_with_prefix(name), value)
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
- statsd_client.timing(metric_name_with_prefix(name), (time.real * 1000).floor)
28
+ submit(name, (time.real * 1000).floor, :timing)
23
29
 
24
30
  result
25
31
  end
@@ -1,3 +1,3 @@
1
1
  class Watchman
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rt-watchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rendered Text