meter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module Meter
5
5
  class Configuration
6
6
 
7
7
  attr_accessor :logger, :tags
8
- attr_reader :primary_backend, :secondary_backend
8
+ attr_reader :primary_backend, :secondary_backend, :counter_backend
9
9
 
10
10
  def initialize(options={})
11
11
  @logger = options[:logger] || default_logger
@@ -17,12 +17,19 @@ module Meter
17
17
  @secondary_backend.host = options[:secondary_host] || default_host
18
18
  @secondary_backend.port = options[:secondary_port] || default_secondary_port
19
19
  @secondary_backend.namespace = options[:namespace] || default_namespace
20
+
21
+ @counter_backend = Backend.new
22
+ @counter_backend.host = options[:counter_host] || default_host
23
+ @counter_backend.port = options[:counter_port] || default_counter_port
24
+ @counter_backend.namespace = options[:namespace] || default_namespace
25
+
20
26
  @tags = options[:tags] || {}
21
27
  end
22
28
 
23
29
  def namespace=(new_namespace)
24
30
  primary_backend.namespace = new_namespace
25
31
  secondary_backend.namespace = new_namespace
32
+ counter_backend.namespace = new_namespace
26
33
  end
27
34
 
28
35
  def namespace
@@ -80,6 +87,10 @@ module Meter
80
87
  end
81
88
 
82
89
  def default_secondary_port
90
+ 8126
91
+ end
92
+
93
+ def default_counter_port
83
94
  3333
84
95
  end
85
96
 
data/lib/meter/version.rb CHANGED
@@ -2,7 +2,7 @@ module Meter
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
data/lib/meter.rb CHANGED
@@ -8,25 +8,29 @@ module Meter
8
8
  def increment(key, options = {})
9
9
  id = options.delete(:id)
10
10
  primary.increment key, options
11
+ secondary.increment key, options
11
12
  if id
12
- secondary.increment "#{key}.#{id}", options
13
+ counter.increment "#{key}.#{id}", options
13
14
  end
14
15
  end
15
16
 
16
17
  def count(key, delta, options = {})
17
18
  id = options.delete(:id)
18
19
  primary.count key, delta, options
20
+ secondary.count key, delta, options
19
21
  if id
20
- secondary.count "#{key}.#{id}", delta, options
22
+ counter.count "#{key}.#{id}", delta, options
21
23
  end
22
24
  end
23
25
 
24
26
  def gauge(key, value, options = {})
25
27
  primary.gauge key, value, options
28
+ secondary.gauge key, value, options
26
29
  end
27
30
 
28
31
  def histogram(key, value, options = {})
29
32
  primary.histogram key, value, options
33
+ secondary.histogram key, value, options
30
34
  end
31
35
 
32
36
  private
@@ -39,4 +43,8 @@ module Meter
39
43
  config.secondary_backend
40
44
  end
41
45
 
46
+ def counter
47
+ config.counter_backend
48
+ end
49
+
42
50
  end
@@ -52,7 +52,7 @@ describe Meter::Configuration do
52
52
 
53
53
  it 'has the default port' do
54
54
  config.primary_backend.port.should == 8125
55
- config.secondary_backend.port.should == 3333
55
+ config.secondary_backend.port.should == 8126
56
56
  end
57
57
  end
58
58
 
@@ -5,28 +5,31 @@ describe Meter do
5
5
  let(:meter) { Meter }
6
6
  let(:primary) { Meter.config.primary_backend }
7
7
  let(:secondary) { Meter.config.secondary_backend }
8
+ let(:counter) { Meter.config.counter_backend }
8
9
 
9
10
  describe '.increment' do
10
11
  context "when given an id as option" do
11
- it "proxies to the secondary with the id" do
12
- secondary.should_receive(:increment).with("my.key.123", {})
12
+ it "proxies to the counter with the id" do
13
+ counter.should_receive(:increment).with("my.key.123", {})
13
14
  meter.increment 'my.key', :id => 123
14
15
  end
15
16
 
16
- it "proxies to the primary without the id" do
17
+ it "proxies to the primary and secondary without the id" do
17
18
  primary.should_receive(:increment).with("my.key", {})
19
+ secondary.should_receive(:increment).with("my.key", {})
18
20
  meter.increment 'my.key', :id => 123
19
21
  end
20
22
  end
21
23
 
22
24
  context "when id is NOT given as an option" do
23
- it "doesn't proxy to the secondary at all" do
24
- secondary.should_not_receive(:increment)
25
+ it "doesn't proxy to the counter at all" do
26
+ counter.should_not_receive(:increment)
25
27
  meter.increment 'my.key'
26
28
  end
27
29
 
28
- it "proxies to the primary" do
30
+ it "proxies to the primary and secondary" do
29
31
  primary.should_receive(:increment).with("my.key", {})
32
+ secondary.should_receive(:increment).with("my.key", {})
30
33
  meter.increment 'my.key'
31
34
  end
32
35
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: meter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - bukowskis
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-13 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement