metriks 0.9.6 → 0.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/lib/metriks.rb +1 -1
- data/lib/metriks/reporter/graphite.rb +1 -1
- data/lib/metriks/reporter/librato_metrics.rb +1 -1
- data/lib/metriks/reporter/logger.rb +1 -1
- data/lib/metriks/reporter/proc_title.rb +2 -2
- data/metriks.gemspec +3 -2
- data/test/graphite_reporter_test.rb +8 -1
- data/test/librato_metrics_reporter_test.rb +8 -1
- data/test/logger_reporter_test.rb +8 -1
- data/test/riemann_reporter_test.rb +11 -4
- data/test/thread_error_handling_tests.rb +20 -0
- metadata +4 -3
data/lib/metriks.rb
CHANGED
@@ -5,7 +5,7 @@ module Metriks::Reporter
|
|
5
5
|
@prefix = options[:prefix] || $0.dup
|
6
6
|
|
7
7
|
@interval = options[:interval] || 5
|
8
|
-
@
|
8
|
+
@on_error = options[:on_error] || proc { |ex| }
|
9
9
|
|
10
10
|
@metrics = []
|
11
11
|
end
|
@@ -29,7 +29,7 @@ module Metriks::Reporter
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
rescue Exception => ex
|
32
|
-
@
|
32
|
+
@on_error[ex] rescue nil
|
33
33
|
end
|
34
34
|
sleep @interval
|
35
35
|
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 = 'metriks'
|
16
|
-
s.version = '0.9.
|
17
|
-
s.date = '2012-03-
|
16
|
+
s.version = '0.9.7'
|
17
|
+
s.date = '2012-03-21'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -87,6 +87,7 @@ Gem::Specification.new do |s|
|
|
87
87
|
test/registry_test.rb
|
88
88
|
test/riemann_reporter_test.rb
|
89
89
|
test/test_helper.rb
|
90
|
+
test/thread_error_handling_tests.rb
|
90
91
|
test/timer_test.rb
|
91
92
|
test/utilization_timer_test.rb
|
92
93
|
]
|
@@ -1,11 +1,18 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'thread_error_handling_tests'
|
2
3
|
|
3
4
|
require 'metriks/reporter/graphite'
|
4
5
|
|
5
6
|
class GraphiteReporterTest < Test::Unit::TestCase
|
7
|
+
include ThreadErrorHandlingTests
|
8
|
+
|
9
|
+
def build_reporter(options={})
|
10
|
+
Metriks::Reporter::Graphite.new('localhost', 3333, { :registry => @registry }.merge(options))
|
11
|
+
end
|
12
|
+
|
6
13
|
def setup
|
7
14
|
@registry = Metriks::Registry.new
|
8
|
-
@reporter =
|
15
|
+
@reporter = build_reporter
|
9
16
|
@stringio = StringIO.new
|
10
17
|
|
11
18
|
@reporter.stubs(:socket).returns(@stringio)
|
@@ -1,11 +1,18 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'thread_error_handling_tests'
|
2
3
|
|
3
4
|
require 'metriks/reporter/librato_metrics'
|
4
5
|
|
5
6
|
class LibratoMetricsReporterTest < Test::Unit::TestCase
|
7
|
+
include ThreadErrorHandlingTests
|
8
|
+
|
9
|
+
def build_reporter(options={})
|
10
|
+
Metriks::Reporter::LibratoMetrics.new('user', 'password', { :registry => @registry }.merge(options))
|
11
|
+
end
|
12
|
+
|
6
13
|
def setup
|
7
14
|
@registry = Metriks::Registry.new
|
8
|
-
@reporter =
|
15
|
+
@reporter = build_reporter
|
9
16
|
end
|
10
17
|
|
11
18
|
def teardown
|
@@ -1,15 +1,22 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'thread_error_handling_tests'
|
2
3
|
|
3
4
|
require 'logger'
|
4
5
|
require 'metriks/reporter/logger'
|
5
6
|
|
6
7
|
class LoggerReporterTest < Test::Unit::TestCase
|
8
|
+
include ThreadErrorHandlingTests
|
9
|
+
|
10
|
+
def build_reporter(options={})
|
11
|
+
Metriks::Reporter::Logger.new({ :registry => @registry, :logger => @logger }.merge(options))
|
12
|
+
end
|
13
|
+
|
7
14
|
def setup
|
8
15
|
@stringio = StringIO.new
|
9
16
|
@logger = ::Logger.new(@stringio)
|
10
17
|
@registry = Metriks::Registry.new
|
11
18
|
|
12
|
-
@reporter =
|
19
|
+
@reporter = build_reporter
|
13
20
|
|
14
21
|
@registry.meter('meter.testing').mark
|
15
22
|
@registry.counter('counter.testing').increment
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'thread_error_handling_tests'
|
2
3
|
|
3
4
|
# riemann only works in 1.9
|
4
5
|
if RUBY_VERSION > '1.9'
|
@@ -6,14 +7,20 @@ if RUBY_VERSION > '1.9'
|
|
6
7
|
require 'metriks/reporter/riemann'
|
7
8
|
|
8
9
|
class RiemannReporterTest < Test::Unit::TestCase
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
include ThreadErrorHandlingTests
|
11
|
+
|
12
|
+
def build_reporter(options={})
|
13
|
+
Metriks::Reporter::Riemann.new({
|
12
14
|
:host => "foo",
|
13
15
|
:port => 1234,
|
14
16
|
:registry => @registry,
|
15
17
|
:default_event => {:host => "h"}
|
16
|
-
)
|
18
|
+
}.merge(options))
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
@registry = Metriks::Registry.new
|
23
|
+
@reporter = build_reporter
|
17
24
|
end
|
18
25
|
|
19
26
|
def teardown
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ThreadErrorHandlingTests
|
2
|
+
def test_passes_errors_in_thread_loop_to_on_error_handler
|
3
|
+
rescued_error = nil
|
4
|
+
error_handler_called = false
|
5
|
+
reporter = build_reporter(:interval => 0.0001, :on_error => lambda { |e|
|
6
|
+
error_handler_called = true
|
7
|
+
rescued_error = e
|
8
|
+
})
|
9
|
+
|
10
|
+
reporter.stubs(:write).raises(StandardError, "boom")
|
11
|
+
|
12
|
+
reporter.start
|
13
|
+
sleep 0.002
|
14
|
+
assert_equal true, error_handler_called
|
15
|
+
assert_equal "boom", rescued_error.message
|
16
|
+
ensure
|
17
|
+
reporter.stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 7
|
9
|
+
version: 0.9.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eric Lindvall
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-03-
|
17
|
+
date: 2012-03-21 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- test/registry_test.rb
|
115
115
|
- test/riemann_reporter_test.rb
|
116
116
|
- test/test_helper.rb
|
117
|
+
- test/thread_error_handling_tests.rb
|
117
118
|
- test/timer_test.rb
|
118
119
|
- test/utilization_timer_test.rb
|
119
120
|
has_rdoc: true
|