knotice-ruby-statsd 0.0.2 → 0.0.3

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 +19 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTdlYmRhMzA2NDg1ZmZkNTY1ZTJhMGU1YTNlMDExN2E1Njg0YjY2Ng==
4
+ MzQxZTQ0NmY5YjhmOWIyZGU3ZDVmNGIwZmJmYWQ5ZDNhYmQwYmFkNw==
5
5
  data.tar.gz: !binary |-
6
- OWI4YmU3ZDY1YjU5ZTllNmY0ZTIzZmUxMjA2Nzk1MTcwNzUyY2QwZg==
6
+ Y2RlMGE3ZWU3YmJiODk4ZDRjNTg3MjEwNTQ1NDRlYmQ3YmI0NjhkMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTg1MmIwNDlhNzE2ZTY4ZjdkNGQ1MzY1MjhlNmYwNGQ0MTMxYWE5YmZlMGVj
10
- MmQxMzRlZDkyYjFiNjJlNDlhMTZjY2M2YTQ3ZGFkYmQ1NjlhM2JjMWU4MDlm
11
- OGQ2YjFlZjFiMDZjNTQ0Njc5ODgyNTE3MGQ2Y2RjYWQ0Y2UwMmU=
9
+ NjRhM2ZmNmRkZDY1NmRlYTg5Yjc2MzFkZjYzNjg5ZjBiZWMyMzUzOGQ2ZDA4
10
+ OTM5NjExZjQ5ZWExYmNlMDk0NjMzZjNjN2Q5ODhlNjExNjU3MzlmNTMxNmYx
11
+ NTdkNjEwYTBjNDcyZGQ5YTVjOGJkMmRlZTE0NzQ3ZTlmYTc2MWI=
12
12
  data.tar.gz: !binary |-
13
- NTVjOTNjZWFlODY2Y2JiZDdhZTY0YTFiOGIyNmI1MzY4ZTVjOGVlM2JhM2Nm
14
- MWViN2Y4ZDFhMTQ2ZDc0NmI0YjBkNTM5OTg2NDljYzg2NGJiMjA3NjQ2NTNj
15
- NDUwNGViMzkwYWQ4NzFhNTNhNTY3OWI4YTIyZDYxMzYxYzg3ZjU=
13
+ OGE4MGU4ODQzNmU0NjZmNTU0MGY2NmEzY2FmMWRlZGYwZjAyYTA4MWVjMDQ2
14
+ YzBhMTQ3MDQyMjk0ZGJkNTE0ZmFkYmRiN2Y2ZjQ3MzVkNzMyNWU4NDY2N2I3
15
+ NmFhNjI2Yzg5NjJmOGNiNWYxOTk0ZDVhNjYyZjU0YzFmZGQ4NGM=
data/lib/kstatsd.rb CHANGED
@@ -8,28 +8,35 @@ class Kstatsd
8
8
  end
9
9
  end
10
10
 
11
- def increment(bucket)
12
- $statsd.increment bucket
11
+ def increment(bucket, sr=1)
12
+ $statsd.increment bucket,sr
13
13
  end
14
14
 
15
- def timing(bucket,ms)
16
- $statsd.timing bucket,ms
15
+ def decrement(bucket, sr=1)
16
+ $statsd.increment bucket,sr
17
17
  end
18
18
 
19
- def gauge (bucket, ms)
20
- $statsd.gauge bucket, ms
19
+ def timing(bucket,ms, sr=1)
20
+ $statsd.timing bucket,ms,sr
21
+ end
22
+
23
+ def gauge (bucket, ms, sr=1)
24
+ $statsd.gauge bucket, ms,sr
21
25
  end
22
26
 
23
- def timeEnd(bucket,startTime)
24
- $statsd.timing bucket, time_diff_milli(startTime)
27
+ def timeEnd(bucket,startTime, sr=1)
28
+ $statsd.timing bucket, time_diff_milli(startTime),sr
25
29
  end
26
30
 
31
+ def time (bucket,sr=1)
32
+ $statsd.time(bucket,sr) { yield }
33
+ end
34
+
27
35
  def time_diff_milli(start)
28
-
29
36
  finish = Time.now
30
- puts 'start' + start.to_s
31
- puts 'finish' + finish.to_s
32
- return (((finish - start)* 1000.0).to_i).to_s
37
+ #puts 'start' + start.to_s
38
+ #puts 'finish' + finish.to_s
39
+ return ((finish - start)* 1000.0).round
33
40
  end
34
41
 
35
42
  end
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darshan Pradhan