fiveruns-dash-ruby 0.8.8 → 0.8.9
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/fiveruns/dash/configuration.rb +4 -0
- data/lib/fiveruns/dash/exception_recorder.rb +21 -3
- data/lib/fiveruns/dash/session.rb +1 -1
- data/test/configuration_test.rb +13 -1
- data/test/exception_recorder_test.rb +11 -0
- data/test/session_test.rb +30 -1
- data/version.yml +1 -1
- metadata +2 -3
@@ -58,15 +58,21 @@ module Fiveruns
|
|
58
58
|
@session = session
|
59
59
|
end
|
60
60
|
|
61
|
+
def exception_annotations
|
62
|
+
@exception_annotaters ||= []
|
63
|
+
end
|
64
|
+
|
61
65
|
def ignore_exception?(exception)
|
62
66
|
RULES.any? do |rule|
|
63
67
|
rule.call(exception)
|
64
68
|
end
|
65
69
|
end
|
66
|
-
|
70
|
+
|
67
71
|
def record(exception, sample=nil)
|
68
72
|
return if ignore_exception? exception
|
69
|
-
|
73
|
+
|
74
|
+
run_annotations(sample)
|
75
|
+
|
70
76
|
data = extract_data_from_exception(exception)
|
71
77
|
# Allow the sample data to override the exception's display name.
|
72
78
|
data[:name] = sample.delete(:name) if sample and sample[:name]
|
@@ -91,11 +97,23 @@ module Fiveruns
|
|
91
97
|
def reset
|
92
98
|
exceptions.clear
|
93
99
|
end
|
94
|
-
|
100
|
+
|
101
|
+
def add_annotation(&annotation)
|
102
|
+
exception_annotations << annotation
|
103
|
+
end
|
104
|
+
|
95
105
|
#######
|
96
106
|
private
|
97
107
|
#######
|
98
108
|
|
109
|
+
def run_annotations(sample)
|
110
|
+
exception_annotations.each do |annotation|
|
111
|
+
annotation.call(sample)
|
112
|
+
end
|
113
|
+
|
114
|
+
return sample
|
115
|
+
end
|
116
|
+
|
99
117
|
def flatten_sample(sample)
|
100
118
|
case sample
|
101
119
|
when Hash
|
data/test/configuration_test.rb
CHANGED
@@ -79,7 +79,19 @@ class ConfigurationTest < Test::Unit::TestCase
|
|
79
79
|
assert_equal %w(bar foo), @config.metrics.map { |m| m.name }.map { |i| i.to_s }.sort
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
|
+
context 'for exception annotations' do
|
84
|
+
should 'add a block to the list of annotations' do
|
85
|
+
config.annotate_exceptions do |metadata|
|
86
|
+
metadata[:foo] = 'flop!'
|
87
|
+
end
|
88
|
+
|
89
|
+
assert_equal 1,
|
90
|
+
::Fiveruns::Dash.session.
|
91
|
+
exception_recorder.exception_annotations.length
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
83
95
|
end
|
84
96
|
|
85
97
|
#######
|
@@ -69,6 +69,17 @@ class ExceptionRecorderTest < Test::Unit::TestCase
|
|
69
69
|
should "not serialize sample" do
|
70
70
|
assert_equal({'key' => 'value'}, recorder.data.first[:sample])
|
71
71
|
end
|
72
|
+
should 'run annotations on exception samples' do
|
73
|
+
recorder.reset
|
74
|
+
recorder.add_annotation do |metadata|
|
75
|
+
metadata.delete :key
|
76
|
+
metadata[:foo] = 1
|
77
|
+
'flop'
|
78
|
+
end
|
79
|
+
recorder.record(build('Some exception'), {:key => 1})
|
80
|
+
|
81
|
+
assert_equal({'foo' => '1'}, recorder.data.first[:sample])
|
82
|
+
end
|
72
83
|
end
|
73
84
|
|
74
85
|
context "when recording exceptions with the same message and backtrace" do
|
data/test/session_test.rb
CHANGED
@@ -43,7 +43,36 @@ class SessionTest < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
|
+
context "exceptions" do
|
48
|
+
|
49
|
+
setup do
|
50
|
+
@ex = generate_exception
|
51
|
+
end
|
52
|
+
|
53
|
+
should 'add exceptions to the exception recorder' do
|
54
|
+
@session.add_exception(@ex)
|
55
|
+
|
56
|
+
assert_exception_matches @ex, @session.exception_recorder.data.first
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def assert_exception_matches(exception, hash)
|
66
|
+
assert_equal exception.class.to_s, hash[:name]
|
67
|
+
assert_equal exception.message, hash[:message]
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate_exception
|
71
|
+
begin
|
72
|
+
raise Exception.new("OHS NOES")
|
73
|
+
rescue Exception => e
|
74
|
+
e
|
75
|
+
end
|
47
76
|
end
|
48
77
|
|
49
78
|
end
|
data/version.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiveruns-dash-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FiveRuns Development Team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-25 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -32,7 +32,6 @@ files:
|
|
32
32
|
- lib/fiveruns/dash/host.rb
|
33
33
|
- lib/fiveruns/dash/instrument.rb
|
34
34
|
- lib/fiveruns/dash/metric.rb
|
35
|
-
- lib/fiveruns/dash/read
|
36
35
|
- lib/fiveruns/dash/recipe.rb
|
37
36
|
- lib/fiveruns/dash/reporter.rb
|
38
37
|
- lib/fiveruns/dash/scm.rb
|