dawanda-statsd-client 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dawanda-statsd-client}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Taylor"]
12
- s.date = %q{2011-02-23}
12
+ s.date = %q{2011-02-24}
13
13
  s.default_executable = %q{statsd-send}
14
14
  s.description = %q{A Ruby client for statsd}
15
15
  s.email = %q{tom@tomtaylor.co.uk}
data/lib/statsd/client.rb CHANGED
@@ -5,14 +5,26 @@ require 'yaml'
5
5
  class Statsd
6
6
  class << self
7
7
  def increment(metric, options={})
8
- value = options.is_a?(Fixnum) ? options : (options[:by] || 1)
9
- client.update_stats(metric, value*factor, (options[:sample_rate] || 1))
8
+ if options.is_a?(Fixnum)
9
+ value = options
10
+ sample_rate = 1
11
+ else
12
+ value = (options[:by] || 1)
13
+ sample_rate = (options[:sample_rate] || 1)
14
+ end
15
+ client.update_stats(metric, value*factor, sample_rate)
10
16
  end
11
17
  alias_method :inc, :increment
12
18
 
13
19
  def decrement(metric, options={})
14
- value = options.is_a?(Fixnum) ? options : (options[:by] || 1)
15
- client.update_stats(metric, value*factor*(-1), (options[:sample_rate] || 1))
20
+ if options.is_a?(Fixnum)
21
+ value = options
22
+ sample_rate = 1
23
+ else
24
+ value = (options[:by] || 1)
25
+ sample_rate = (options[:sample_rate] || 1)
26
+ end
27
+ client.update_stats(metric, value*factor*(-1), sample_rate)
16
28
  end
17
29
  alias_method :dec, :decrement
18
30
 
@@ -123,6 +135,7 @@ class Statsd
123
135
  private
124
136
 
125
137
  def send(data, sample_rate = 1)
138
+ puts "sending #{data} with sample #{sample_rate}"
126
139
  sampled_data = {}
127
140
 
128
141
  if sample_rate < 1
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dawanda-statsd-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Taylor
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 +01:00
18
+ date: 2011-02-24 00:00:00 +01:00
19
19
  default_executable: statsd-send
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency