knotice-ruby-statsd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/kstatsd.rb +8 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzQzNmNiMmZjYmM3ZjRiZGM1MWJjYjdmMzRhMWRmMmFkMGZlNTU5Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGQ1NDNmMmM3OWVmMDE0ZmMzYjAyMjczOGUzMmUzMzgxN2UwYTM3NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTMyZTNmY2YzODhjNTc3NjRhZWQxNTAyYzY4NmE4N2U4ZGYzYzdmOWZiMjFh
|
10
|
+
M2NmMDlhNjJmYjViYmU1M2FiYWE0YjEyZWIzNzQ2MmUzOGQ2Mjg2YTUyZmE3
|
11
|
+
MTFiZTQ1YjYzNjlhNWQ2ZjVmYmQ2YmJhNzY4MTEwYWNjYjBjMDg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjQ2YjI4YTVjNDI1MjQ3Y2FkYTgxNGU4ODA3ZDNiZWRmZjJhYzVmYzZmNzRk
|
14
|
+
NDc0ZjI1NjFmNzM3MzZhZjExMGQ3NGQ2MWI3YjIzZGYzZjE5ZThjZTlmZTU1
|
15
|
+
NzgyZDNmNTIwYzFhNWFiZWQxODQ3Zjc0YzhhMDI5MzNjN2U5MzI=
|
data/lib/kstatsd.rb
CHANGED
@@ -2,40 +2,39 @@ require 'statsd'
|
|
2
2
|
|
3
3
|
class Kstatsd
|
4
4
|
|
5
|
-
def initialize(serverhost,serverport)
|
5
|
+
def initialize(serverhost,serverport,enabled=true)
|
6
6
|
if($statsd == nil)
|
7
7
|
$statsd = Statsd.new serverhost,serverport
|
8
8
|
end
|
9
|
+
$enabled = enabled
|
9
10
|
end
|
10
11
|
|
11
12
|
def increment(bucket, sr=1)
|
12
|
-
$statsd.increment bucket,sr
|
13
|
+
$statsd.increment bucket,sr if $enabled == true
|
13
14
|
end
|
14
15
|
|
15
16
|
def decrement(bucket, sr=1)
|
16
|
-
$statsd.
|
17
|
+
$statsd.decrement bucket,sr if $enabled == true
|
17
18
|
end
|
18
19
|
|
19
20
|
def timing(bucket,ms, sr=1)
|
20
|
-
$statsd.timing bucket,ms,sr
|
21
|
+
$statsd.timing bucket,ms,sr if $enabled == true
|
21
22
|
end
|
22
23
|
|
23
24
|
def gauge (bucket, ms, sr=1)
|
24
|
-
$statsd.gauge bucket, ms,sr
|
25
|
+
$statsd.gauge bucket, ms,sr if $enabled == true
|
25
26
|
end
|
26
27
|
|
27
28
|
def timeEnd(bucket,startTime, sr=1)
|
28
|
-
$statsd.timing bucket, time_diff_milli(startTime),sr
|
29
|
+
$statsd.timing bucket, time_diff_milli(startTime),sr if $enabled == true
|
29
30
|
end
|
30
31
|
|
31
32
|
def time (bucket,sr=1)
|
32
|
-
$statsd.time(bucket,sr) { yield }
|
33
|
+
$statsd.time(bucket,sr) { yield } if $enabled == true
|
33
34
|
end
|
34
35
|
|
35
36
|
def time_diff_milli(start)
|
36
37
|
finish = Time.now
|
37
|
-
#puts 'start' + start.to_s
|
38
|
-
#puts 'finish' + finish.to_s
|
39
38
|
return ((finish - start)* 1000.0).round
|
40
39
|
end
|
41
40
|
|