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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/kstatsd.rb +8 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzQxZTQ0NmY5YjhmOWIyZGU3ZDVmNGIwZmJmYWQ5ZDNhYmQwYmFkNw==
4
+ YzQzNmNiMmZjYmM3ZjRiZGM1MWJjYjdmMzRhMWRmMmFkMGZlNTU5Yw==
5
5
  data.tar.gz: !binary |-
6
- Y2RlMGE3ZWU3YmJiODk4ZDRjNTg3MjEwNTQ1NDRlYmQ3YmI0NjhkMg==
6
+ OGQ1NDNmMmM3OWVmMDE0ZmMzYjAyMjczOGUzMmUzMzgxN2UwYTM3NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjRhM2ZmNmRkZDY1NmRlYTg5Yjc2MzFkZjYzNjg5ZjBiZWMyMzUzOGQ2ZDA4
10
- OTM5NjExZjQ5ZWExYmNlMDk0NjMzZjNjN2Q5ODhlNjExNjU3MzlmNTMxNmYx
11
- NTdkNjEwYTBjNDcyZGQ5YTVjOGJkMmRlZTE0NzQ3ZTlmYTc2MWI=
9
+ OTMyZTNmY2YzODhjNTc3NjRhZWQxNTAyYzY4NmE4N2U4ZGYzYzdmOWZiMjFh
10
+ M2NmMDlhNjJmYjViYmU1M2FiYWE0YjEyZWIzNzQ2MmUzOGQ2Mjg2YTUyZmE3
11
+ MTFiZTQ1YjYzNjlhNWQ2ZjVmYmQ2YmJhNzY4MTEwYWNjYjBjMDg=
12
12
  data.tar.gz: !binary |-
13
- OGE4MGU4ODQzNmU0NjZmNTU0MGY2NmEzY2FmMWRlZGYwZjAyYTA4MWVjMDQ2
14
- YzBhMTQ3MDQyMjk0ZGJkNTE0ZmFkYmRiN2Y2ZjQ3MzVkNzMyNWU4NDY2N2I3
15
- NmFhNjI2Yzg5NjJmOGNiNWYxOTk0ZDVhNjYyZjU0YzFmZGQ4NGM=
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.increment bucket,sr
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knotice-ruby-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darshan Pradhan