rubycut-metriks 0.9.9.6 → 0.9.9.7

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/Gemfile CHANGED
@@ -3,6 +3,7 @@ source :rubygems
3
3
  gemspec
4
4
 
5
5
  group :test do
6
+ gem 'ruby-debug'
6
7
  gem 'rake', '0.8.7'
7
8
  gem 'riemann-client', '~> 0.0.7'
8
9
  gem 'rbtree', :platform => :mri_18
@@ -4,6 +4,8 @@ module Metriks
4
4
  # Public: Counters are one of the simplest metrics whose only operations
5
5
  # are increment and decrement.
6
6
  class Counter
7
+ # sometimes I have multiple processes that count values, so I need to reset every time after submit
8
+ attr_accessor :reset_on_submit
7
9
  # Public: Initialize a new Counter.
8
10
  def initialize
9
11
  @count = Atomic.new(0)
@@ -60,6 +60,7 @@ module Metriks::Reporter
60
60
  send_metric name, metric, [
61
61
  :count
62
62
  ]
63
+ metric.clear if metric.reset_on_submit
63
64
  when Metriks::Gauge
64
65
  send_metric name, metric, [
65
66
  :value
@@ -102,6 +103,7 @@ module Metriks::Reporter
102
103
  def send_metric(compound_name, metric, keys, snapshot_keys = [])
103
104
  name, tags = compound_name.split("#")
104
105
  keys.each do |key|
106
+ puts "put #{name}.#{key} #{Time.now.to_i} #{metric.send(key)} #{tags}"
105
107
  connection.puts("put #{name}.#{key} #{Time.now.to_i} #{metric.send(key)} #{tags}")
106
108
  end
107
109
  end
data/metriks.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'rubycut-metriks'
16
- s.version = '0.9.9.6'
17
- s.date = '2013-04-28'
16
+ s.version = '0.9.9.7'
17
+ s.date = '2013-05-20'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
  require 'thread_error_handling_tests'
3
-
3
+ require 'ruby-debug'
4
4
  require 'metriks/reporter/opentsdb'
5
5
 
6
6
  class OpentsdbReporterTest < Test::Unit::TestCase
@@ -29,6 +29,7 @@ class OpentsdbReporterTest < Test::Unit::TestCase
29
29
  @registry.gauge('gauge.testing#tag=test') { 123 }
30
30
  tcp_socket = mock
31
31
  @reporter.stubs(:connection).returns(tcp_socket)
32
+ @reporter.stubs(:open_connection).returns(nil)
32
33
  tcp_socket.expects(:puts).at_least_once
33
34
  tcp_socket.expects(:ready?).returns(false)
34
35
  tcp_socket.expects(:close)
@@ -36,4 +37,20 @@ class OpentsdbReporterTest < Test::Unit::TestCase
36
37
  @reporter.connection.expects(:puts).with("put counter.testing.count #{Time.now.to_i} 1 tag=test")
37
38
  @reporter.write
38
39
  end
40
+ def test_reset
41
+
42
+ counter = @registry.counter('counter.testing#tag=test')
43
+ counter.increment
44
+ counter.reset_on_submit = true
45
+ assert_equal @registry.counter('counter.testing#tag=test').count, 1
46
+ tcp_socket = mock
47
+ @reporter.stubs(:connection).returns(tcp_socket)
48
+ tcp_socket.expects(:puts).at_least_once
49
+ tcp_socket.expects(:ready?).returns(false)
50
+ tcp_socket.expects(:close)
51
+
52
+ @reporter.stubs(:open_connection).returns(nil)
53
+ @reporter.write
54
+ assert_equal @registry.counter('counter.testing#tag=test').count, 0
55
+ end
39
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycut-metriks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 9
10
- - 6
11
- version: 0.9.9.6
10
+ - 7
11
+ version: 0.9.9.7
12
12
  platform: ruby
13
13
  authors:
14
14
  - Eric Lindvall
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-04-28 00:00:00 Z
19
+ date: 2013-05-20 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: atomic
@@ -177,4 +177,3 @@ test_files:
177
177
  - test/timer_test.rb
178
178
  - test/utilization_timer_test.rb
179
179
  - test/opentsdb_metrics_reporter_test.rb
180
- has_rdoc: