observed 0.1.1 → 0.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/.travis.yml +4 -0
- data/README.md +53 -78
- data/examples/observed.rb +1 -1
- data/exe/observed-oneshot +3 -1
- data/features/explicit_routing.feature +33 -0
- data/features/oneshot.feature +4 -0
- data/features/test_in_single_ruby_source.feature +4 -0
- data/integrations/observed-clockwork/features/run_observed_inside_clockwork.feature +6 -7
- data/integrations/observed-clockwork/lib/observed/clockwork/version.rb +1 -1
- data/integrations/observed-clockwork/lib/observed/clockwork.rb +0 -1
- data/integrations/observed-clockwork/observed-clockwork.gemspec +1 -1
- data/integrations/observed-eventmachine/.gitignore +17 -0
- data/integrations/observed-eventmachine/Gemfile +8 -0
- data/integrations/observed-eventmachine/LICENSE.txt +22 -0
- data/integrations/observed-eventmachine/README.md +29 -0
- data/integrations/observed-eventmachine/Rakefile +1 -0
- data/integrations/observed-eventmachine/examples/observed.rb +30 -0
- data/integrations/observed-eventmachine/features/integration_via_single_ruby_source.feature +48 -0
- data/integrations/observed-eventmachine/features/support/env.rb +8 -0
- data/integrations/observed-eventmachine/lib/observed/eventmachine/version.rb +5 -0
- data/integrations/observed-eventmachine/lib/observed/eventmachine.rb +70 -0
- data/integrations/observed-eventmachine/observed-eventmachine.gemspec +28 -0
- data/lib/observed/application/oneshot.rb +14 -37
- data/lib/observed/builtin_plugins/file.rb +5 -14
- data/lib/observed/builtin_plugins/stdout.rb +7 -14
- data/lib/observed/config.rb +4 -4
- data/lib/observed/config_builder.rb +154 -87
- data/lib/observed/config_dsl.rb +2 -8
- data/lib/observed/configurable.rb +61 -3
- data/lib/observed/context.rb +90 -0
- data/lib/observed/default/observer.rb +2 -5
- data/lib/observed/default.rb +0 -1
- data/lib/observed/event_bus.rb +31 -0
- data/lib/observed/execution_job_factory.rb +95 -0
- data/lib/observed/job.rb +163 -0
- data/lib/observed/jobbed_event_bus.rb +33 -0
- data/lib/observed/logging.rb +40 -0
- data/lib/observed/observer.rb +1 -0
- data/lib/observed/observer_helpers/timer.rb +13 -5
- data/lib/observed/pluggable.rb +11 -0
- data/lib/observed/reporter/regexp_matching.rb +2 -1
- data/lib/observed/reporter/report_formatting.rb +57 -0
- data/lib/observed/reporter.rb +0 -2
- data/lib/observed/system.rb +11 -78
- data/lib/observed/translator.rb +22 -0
- data/lib/observed/version.rb +1 -1
- data/lib/observed.rb +10 -12
- data/omnibus-observed/.gitignore +9 -0
- data/omnibus-observed/Berksfile +3 -0
- data/omnibus-observed/Berksfile.lock +52 -0
- data/omnibus-observed/Gemfile +4 -0
- data/omnibus-observed/README.md +102 -0
- data/omnibus-observed/Vagrantfile +93 -0
- data/omnibus-observed/config/projects/observed.rb +20 -0
- data/omnibus-observed/config/software/observed.rb +19 -0
- data/omnibus-observed/package-scripts/observed/makeselfinst +27 -0
- data/omnibus-observed/package-scripts/observed/postinst +17 -0
- data/omnibus-observed/package-scripts/observed/postrm +9 -0
- data/plugins/observed-fluentd/lib/observed/fluentd/version.rb +1 -1
- data/plugins/observed-gauge/README.md +5 -0
- data/plugins/observed-gauge/lib/observed/gauge/version.rb +1 -1
- data/plugins/observed-gauge/lib/observed/gauge.rb +11 -13
- data/plugins/observed-gauge/observed-gauge.gemspec +1 -1
- data/plugins/observed-gauge/spec/gauge_spec.rb +7 -7
- data/plugins/observed-growl/Gemfile +6 -0
- data/plugins/observed-growl/lib/observed/growl.rb +80 -0
- data/plugins/observed-http/lib/observed/http/version.rb +1 -1
- data/plugins/observed-http/lib/observed/http.rb +10 -8
- data/plugins/observed-http/observed-http.gemspec +1 -1
- data/plugins/observed-http/spec/http_spec.rb +62 -7
- data/plugins/observed-http/spec/integration_spec.rb +14 -0
- data/plugins/observed-shell/Gemfile +5 -0
- data/plugins/observed-shell/lib/observed/shell.rb +54 -0
- data/run-integration-tests +81 -0
- data/spec/builtin_plugins/stdout_spec.rb +7 -3
- data/spec/config_builder_spec.rb +42 -59
- data/spec/config_dsl_spec.rb +4 -0
- data/spec/configurable_spec.rb +141 -31
- data/spec/event_bus_spec.rb +16 -0
- data/spec/execution_job_factory_spec.rb +35 -0
- data/spec/job_factory_spec.rb +16 -0
- data/spec/job_spec.rb +228 -0
- data/spec/jobbed_event_bus_spec.rb +38 -0
- data/spec/observed_spec.rb +203 -0
- data/spec/observer_helpers/timer_spec.rb +187 -0
- data/spec/oneshot_spec.rb +7 -2
- data/spec/system_spec.rb +5 -39
- metadata +55 -12
- data/lib/observed/default/reporter.rb +0 -17
- data/lib/observed/reader.rb +0 -14
- data/lib/observed/writer.rb +0 -14
- data/spec/reader_spec.rb +0 -15
- data/spec/writer_spec.rb +0 -16
data/spec/observed_spec.rb
CHANGED
@@ -76,4 +76,207 @@ describe Observed do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
describe 'when included' do
|
81
|
+
subject {
|
82
|
+
Module.new do
|
83
|
+
extend Observed
|
84
|
+
end
|
85
|
+
}
|
86
|
+
let(:t) {
|
87
|
+
Time.now
|
88
|
+
}
|
89
|
+
let(:common) {
|
90
|
+
'common'
|
91
|
+
}
|
92
|
+
let(:out) {
|
93
|
+
out = mock('out1')
|
94
|
+
out.expects(:write).with(tag:'t', foo:1, foo2:1, bar:2, bar2:2, baz:3, baz2:3, r3:'common', time: t)
|
95
|
+
.at_least_once
|
96
|
+
out
|
97
|
+
}
|
98
|
+
it 'can be used to define components and trigger them immediately' do
|
99
|
+
report_to_out = subject.report do |data, options|
|
100
|
+
out.write data.merge(baz2:data[:baz]).merge(r3: common).merge(options)
|
101
|
+
end
|
102
|
+
observe_then_translate_then_report = (
|
103
|
+
subject.observe 'foo' do |data|
|
104
|
+
data.merge(foo2:data[:foo],bar:2)
|
105
|
+
end
|
106
|
+
).then(
|
107
|
+
subject.translate do |data, options|
|
108
|
+
data.merge(bar2:data[:bar],baz:3)
|
109
|
+
end
|
110
|
+
).then(
|
111
|
+
report_to_out
|
112
|
+
)
|
113
|
+
|
114
|
+
observe_then_translate_then_report.now({foo:1}, {tag: 't', time: t})
|
115
|
+
|
116
|
+
end
|
117
|
+
context 'with plugins' do
|
118
|
+
before {
|
119
|
+
class TestObserver < Observed::Observer
|
120
|
+
plugin_name 'test1'
|
121
|
+
def observe(data, options)
|
122
|
+
data.merge({foo2:data[:foo],bar:2})
|
123
|
+
end
|
124
|
+
end
|
125
|
+
class TestTranslator < Observed::Translator
|
126
|
+
plugin_name 'test1'
|
127
|
+
def translate(data, options)
|
128
|
+
data.merge({bar2:data[:bar],baz:3})
|
129
|
+
end
|
130
|
+
end
|
131
|
+
class TestReporter < Observed::Reporter
|
132
|
+
plugin_name 'test1'
|
133
|
+
attribute :common
|
134
|
+
include Observed::Reporter::RegexpMatching
|
135
|
+
def report(data, options)
|
136
|
+
out = options[:out]
|
137
|
+
options = options.dup
|
138
|
+
options.delete :out
|
139
|
+
out.write data.merge({baz2:data[:baz],r3:common}.merge(options))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
}
|
143
|
+
it 'can be used to define components from plugins and trigger them immediately' do
|
144
|
+
observe_then_translate_then_report = (subject.observe via: 'test1')
|
145
|
+
.then(subject.translate via: 'test1')
|
146
|
+
.then(subject.report via: 'test1', with: {common: common})
|
147
|
+
|
148
|
+
observe_then_translate_then_report.now({foo:1}, {tag: 't', time: t, out: out})
|
149
|
+
end
|
150
|
+
it 'can be used to send and receive tagged events' do
|
151
|
+
require 'observed/job'
|
152
|
+
require 'observed/jobbed_event_bus'
|
153
|
+
executor = Observed::BlockingJobExecutor.new
|
154
|
+
job_factory = Observed::JobFactory.new(executor: executor)
|
155
|
+
bus = Observed::JobbedEventBus.new(job_factory: job_factory)
|
156
|
+
|
157
|
+
observe_then_send = (subject.observe via: 'test1')
|
158
|
+
.then(bus.pipe_to_emit 'foo')
|
159
|
+
|
160
|
+
bus.receive(/foo/)
|
161
|
+
.then(subject.translate via: 'test1')
|
162
|
+
.then(subject.report via: 'test1', with: {common: common})
|
163
|
+
|
164
|
+
observe_then_send.now({foo:1}, {tag: 't', time: t, out: out})
|
165
|
+
end
|
166
|
+
it 'can be used to send and receive tagged events with the default event bus' do
|
167
|
+
require 'observed/job'
|
168
|
+
|
169
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
170
|
+
|
171
|
+
observe_then_send = (subject.observe via: 'test1')
|
172
|
+
.then(subject.emit 'foo')
|
173
|
+
|
174
|
+
subject.receive(/foo/)
|
175
|
+
.then(subject.translate via: 'test1')
|
176
|
+
.then(subject.report via: 'test1', with: {common: common})
|
177
|
+
|
178
|
+
observe_then_send.now({foo:1}, {tag: 't', time: t, out: out})
|
179
|
+
end
|
180
|
+
it 'provides the way to send the tagged events with a bit shorter code' do
|
181
|
+
require 'observed/job'
|
182
|
+
|
183
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
184
|
+
|
185
|
+
observe_then_send = (subject.observe 'foo', via: 'test1')
|
186
|
+
|
187
|
+
subject.receive(/foo/)
|
188
|
+
.then(subject.translate via: 'test1')
|
189
|
+
.then(subject.report via: 'test1', with: {out: out, common: common})
|
190
|
+
|
191
|
+
observe_then_send.now({foo:1}, {tag: 't', time: t, out: out})
|
192
|
+
end
|
193
|
+
it 'provides the way to receive the tagged events with a bit shorter code' do
|
194
|
+
require 'observed/job'
|
195
|
+
|
196
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
197
|
+
|
198
|
+
observe_then_send = (subject.observe via: 'test1')
|
199
|
+
.then(subject.translate via: 'test1')
|
200
|
+
.then(subject.emit('bar'))
|
201
|
+
|
202
|
+
subject.report /bar/, via: 'test1', with: {out: out, common: common}
|
203
|
+
|
204
|
+
observe_then_send.now({foo:1}, {tag: 't', time: t, out: out})
|
205
|
+
end
|
206
|
+
it 'provides the way to group up observations' do
|
207
|
+
require 'observed/job'
|
208
|
+
|
209
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
210
|
+
|
211
|
+
subject.group :a, [
|
212
|
+
(subject.observe via: 'test1')
|
213
|
+
.then(subject.translate via: 'test1')
|
214
|
+
.then(subject.emit('baz'))
|
215
|
+
]
|
216
|
+
|
217
|
+
subject.report /baz/, via: 'test1', with: {out: out, common: common}
|
218
|
+
|
219
|
+
subject.group(:a).each do |observe_something|
|
220
|
+
observe_something.now({foo:1}, {tag: 't', time: t, out: out})
|
221
|
+
end
|
222
|
+
end
|
223
|
+
it 'provides the way to group up observations by their tags' do
|
224
|
+
require 'observed/job'
|
225
|
+
|
226
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
227
|
+
|
228
|
+
subject.observe 'hoge', via: 'test1'
|
229
|
+
|
230
|
+
subject.receive(/hoge/)
|
231
|
+
.then(subject.translate via: 'test1')
|
232
|
+
.then(subject.report via: 'test1', with: {out: out, common: common})
|
233
|
+
|
234
|
+
subject.group('hoge').each do |observe_something|
|
235
|
+
observe_something.now({foo:1}, {tag: 't', time: t, out: out})
|
236
|
+
end
|
237
|
+
end
|
238
|
+
it 'provides the way to run a group of observations in single method call' do
|
239
|
+
require 'observed/job'
|
240
|
+
|
241
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
242
|
+
|
243
|
+
subject.observe 'hoge', via: 'test1'
|
244
|
+
|
245
|
+
subject.receive(/hoge/)
|
246
|
+
.then(subject.translate via: 'test1')
|
247
|
+
.then(subject.report via: 'test1', with: {out: out, common: common})
|
248
|
+
|
249
|
+
subject.run_group('hoge').now({foo:1}, {tag: 't', time: t, out: out})
|
250
|
+
end
|
251
|
+
it 'provides a short-cut for running a group of observations' do
|
252
|
+
require 'observed/job'
|
253
|
+
|
254
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
255
|
+
|
256
|
+
subject.observe 'fuga', via: 'test1'
|
257
|
+
|
258
|
+
subject.receive(/fuga/)
|
259
|
+
.then(subject.translate via: 'test1')
|
260
|
+
.then(subject.report via: 'test1', with: {out: out, common: common})
|
261
|
+
|
262
|
+
subject.run('fuga', {foo:1}, {tag: 't', time: t, out: out})
|
263
|
+
end
|
264
|
+
it 'provides the default values for the option `tag` and `time`' do
|
265
|
+
require 'observed/job'
|
266
|
+
|
267
|
+
subject.configure executor: Observed::BlockingJobExecutor.new
|
268
|
+
|
269
|
+
subject.observe 't', via: 'test1'
|
270
|
+
|
271
|
+
subject.receive(/t/)
|
272
|
+
.then(subject.translate via: 'test1')
|
273
|
+
.then(subject.report via: 'test1', with: {out: out, common: common})
|
274
|
+
|
275
|
+
::Time.stubs(now: t)
|
276
|
+
|
277
|
+
subject.run('t', {foo:1}, {out: out})
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
79
282
|
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'observed/observer'
|
4
|
+
require 'observed/observer_helpers/timer'
|
5
|
+
require 'observed/configurable'
|
6
|
+
|
7
|
+
describe describe Observed::ObserverHelpers::Timer do
|
8
|
+
|
9
|
+
before {
|
10
|
+
subject.configure system: sys, logger: logger
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:sys) {
|
14
|
+
sys = stub('system')
|
15
|
+
sys.stubs(:now).returns(before).then.returns(after)
|
16
|
+
sys
|
17
|
+
}
|
18
|
+
|
19
|
+
let(:before) { Time.now }
|
20
|
+
|
21
|
+
let(:after) { Time.now + 1 }
|
22
|
+
|
23
|
+
let(:logger) {
|
24
|
+
mock('logger')
|
25
|
+
}
|
26
|
+
|
27
|
+
context 'when included to the new Observer implementation class' do
|
28
|
+
subject {
|
29
|
+
klass = Class.new(Observed::Observer) do
|
30
|
+
include Observed::ObserverHelpers::Timer
|
31
|
+
include Observed::Configurable
|
32
|
+
include Observed::Logging
|
33
|
+
|
34
|
+
def observe(data)
|
35
|
+
[tag, data]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
klass.new
|
39
|
+
}
|
40
|
+
it 'returns the result instead of reporting it via the system' do
|
41
|
+
data = ['test.success', {status: :success, result: 'the result', elapsed_time: after - before }]
|
42
|
+
|
43
|
+
expect(
|
44
|
+
subject.time_and_report(tag: 'test', timeout_in_seconds: 1.0) do
|
45
|
+
'the result'
|
46
|
+
end
|
47
|
+
).to eq(data)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when its logging enabled' do
|
52
|
+
|
53
|
+
subject {
|
54
|
+
klass = Class.new(Observed::Observer) do
|
55
|
+
include Observed::ObserverHelpers::Timer
|
56
|
+
include Observed::Configurable
|
57
|
+
include Observed::Logging
|
58
|
+
end
|
59
|
+
klass.new
|
60
|
+
}
|
61
|
+
|
62
|
+
describe 'its `time` method' do
|
63
|
+
context 'when missing :timeout_in_seconds parameter' do
|
64
|
+
it 'fails' do
|
65
|
+
|
66
|
+
expect {
|
67
|
+
subject.time({}) do
|
68
|
+
fail 'This block should not be called'
|
69
|
+
end
|
70
|
+
}.to raise_error(/The key `:timeout_in_seconds` must be exist in the options/)
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with correct parameters' do
|
76
|
+
context 'given the block which does not time out' do
|
77
|
+
it 'returns the result containing its status, value, elapsed time' do
|
78
|
+
|
79
|
+
expect(
|
80
|
+
subject.time({timeout_in_seconds: 1.0}) do
|
81
|
+
'test_value'
|
82
|
+
end
|
83
|
+
).to eq(status: :success, result: 'test_value', elapsed_time: after - before)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'given the block which does time out' do
|
88
|
+
it 'returns the result containing its status, flag, message while logging the error' do
|
89
|
+
|
90
|
+
logger.expects(:debug).once
|
91
|
+
expect(
|
92
|
+
subject.time(timeout_in_seconds: 1.0) do
|
93
|
+
raise Timeout::Error
|
94
|
+
end
|
95
|
+
).to eq(status: :error, timed_out: true, error: {message: 'Timed out.'})
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'given the block which fails' do
|
101
|
+
it 'returns the result containing its status, message while logging the error' do
|
102
|
+
|
103
|
+
logger.expects(:error).once
|
104
|
+
expect(
|
105
|
+
subject.time(timeout_in_seconds: 1.0) do
|
106
|
+
raise RuntimeError, 'The error message'
|
107
|
+
end
|
108
|
+
).to eq(status: :error, error: {message: 'The error message'})
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when its logging disabled' do
|
119
|
+
|
120
|
+
subject {
|
121
|
+
klass = Class.new(Observed::Observer) do
|
122
|
+
include Observed::ObserverHelpers::Timer
|
123
|
+
include Observed::Configurable
|
124
|
+
end
|
125
|
+
klass.new
|
126
|
+
}
|
127
|
+
|
128
|
+
describe 'its `time` method' do
|
129
|
+
context 'with correct parameters' do
|
130
|
+
context 'given the block which does time out' do
|
131
|
+
it 'returns the result containing its status, flag, message while not logging the error' do
|
132
|
+
|
133
|
+
logger.expects(:debug).never
|
134
|
+
expect(
|
135
|
+
subject.time(timeout_in_seconds: 1.0) do
|
136
|
+
raise Timeout::Error
|
137
|
+
end
|
138
|
+
).to eq(status: :error, error: {message: 'Timed out.'}, timed_out: true)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'given the block which fails' do
|
143
|
+
it 'returns the result containing its status, message while not logging the error' do
|
144
|
+
|
145
|
+
logger.expects(:error).never
|
146
|
+
expect(
|
147
|
+
subject.time(timeout_in_seconds: 1.0) do
|
148
|
+
raise StandardError, 'The error message'
|
149
|
+
end
|
150
|
+
).to eq(status: :error, error: {message: 'The error message'})
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe 'its `time_and_report` method' do
|
158
|
+
context 'when :tag parameter is not given' do
|
159
|
+
it 'fails' do
|
160
|
+
|
161
|
+
expect {
|
162
|
+
subject.time_and_report(timeout_in_seconds: 1.0) do
|
163
|
+
'the result'
|
164
|
+
end
|
165
|
+
}.to raise_error
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'when :tag parameter is given' do
|
171
|
+
it 'reports the result of `time`' do
|
172
|
+
|
173
|
+
data = ['test.success', {status: :success, result: 'the result', elapsed_time: after - before }]
|
174
|
+
|
175
|
+
sys.expects(:report).with(*data).once
|
176
|
+
|
177
|
+
expect(
|
178
|
+
subject.time_and_report(tag: 'test', timeout_in_seconds: 1.0) do
|
179
|
+
'the result'
|
180
|
+
end
|
181
|
+
).to eq(data)
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
data/spec/oneshot_spec.rb
CHANGED
@@ -52,7 +52,12 @@ describe Observed::Application::Oneshot do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
describe '#parse_argv!' do
|
56
|
+
it 'parses ARGV like arrays and extracts Hash objects containing initialization parameters' do
|
57
|
+
argv = %w| -l logfile -d observed.rb foo1 |
|
58
|
+
params = Observed::Application::Oneshot.parse_argv! argv
|
59
|
+
expect(params).to eq({log_file: Pathname.new('logfile'), debug: true, config_file: 'observed.rb'})
|
60
|
+
expect(argv).to eq(%w| foo1 |)
|
61
|
+
end
|
57
62
|
end
|
58
63
|
end
|
data/spec/system_spec.rb
CHANGED
@@ -9,37 +9,6 @@ describe Observed::System do
|
|
9
9
|
Observed::System.new(the_config)
|
10
10
|
}
|
11
11
|
|
12
|
-
context 'with reporters configured' do
|
13
|
-
|
14
|
-
let(:the_config) {
|
15
|
-
s = stub('foo')
|
16
|
-
s.stubs(reporters: [reporter])
|
17
|
-
{ config: s, logger: Logger.new(STDOUT, Logger::DEBUG) }
|
18
|
-
}
|
19
|
-
|
20
|
-
let(:reporter) {
|
21
|
-
s = stub('reporter')
|
22
|
-
s.stubs(match: true)
|
23
|
-
s
|
24
|
-
}
|
25
|
-
|
26
|
-
let(:the_time) {
|
27
|
-
Time.now
|
28
|
-
}
|
29
|
-
|
30
|
-
before {
|
31
|
-
Time.stubs(now: the_time)
|
32
|
-
}
|
33
|
-
|
34
|
-
context 'when the time of a report is omitted' do
|
35
|
-
it 'complements the current time' do
|
36
|
-
reporter.expects(:report).with('the_tag', the_time, {data:1})
|
37
|
-
subject.report('the_tag', {data:1})
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
12
|
context 'with observers configured' do
|
44
13
|
|
45
14
|
let(:observers) {
|
@@ -52,11 +21,15 @@ describe Observed::System do
|
|
52
21
|
c
|
53
22
|
}
|
54
23
|
|
24
|
+
let(:context) {
|
25
|
+
Observed::Context.new
|
26
|
+
}
|
27
|
+
|
55
28
|
let(:the_config) {
|
56
29
|
c = stub('config')
|
57
30
|
c.stubs(observers: observers)
|
58
31
|
c
|
59
|
-
{ config: c, logger: Logger.new(STDOUT, Logger::DEBUG) }
|
32
|
+
{ config: c, logger: Logger.new(STDOUT, Logger::DEBUG), context: context }
|
60
33
|
}
|
61
34
|
|
62
35
|
context 'when there is no matching observer for a tag' do
|
@@ -64,12 +37,5 @@ describe Observed::System do
|
|
64
37
|
expect { subject.run('foo') }.to raise_error(/No configuration found for observation name 'foo'/)
|
65
38
|
end
|
66
39
|
end
|
67
|
-
|
68
|
-
context 'when there is one or more observers matches the tag' do
|
69
|
-
it 'runs the observer' do
|
70
|
-
observer.expects(:observe).once
|
71
|
-
expect { subject.run('bar') }.to_not raise_error
|
72
|
-
end
|
73
|
-
end
|
74
40
|
end
|
75
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: observed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KUOKA Yusuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- examples/00readme/observed.rb
|
142
142
|
- examples/observed.rb
|
143
143
|
- exe/observed-oneshot
|
144
|
+
- features/explicit_routing.feature
|
144
145
|
- features/oneshot.feature
|
145
146
|
- features/support/env.rb
|
146
147
|
- features/test_in_single_ruby_source.feature
|
@@ -161,6 +162,17 @@ files:
|
|
161
162
|
- integrations/observed-clockwork/lib/observed/clockwork.rb
|
162
163
|
- integrations/observed-clockwork/lib/observed/clockwork/version.rb
|
163
164
|
- integrations/observed-clockwork/observed-clockwork.gemspec
|
165
|
+
- integrations/observed-eventmachine/.gitignore
|
166
|
+
- integrations/observed-eventmachine/Gemfile
|
167
|
+
- integrations/observed-eventmachine/LICENSE.txt
|
168
|
+
- integrations/observed-eventmachine/README.md
|
169
|
+
- integrations/observed-eventmachine/Rakefile
|
170
|
+
- integrations/observed-eventmachine/examples/observed.rb
|
171
|
+
- integrations/observed-eventmachine/features/integration_via_single_ruby_source.feature
|
172
|
+
- integrations/observed-eventmachine/features/support/env.rb
|
173
|
+
- integrations/observed-eventmachine/lib/observed/eventmachine.rb
|
174
|
+
- integrations/observed-eventmachine/lib/observed/eventmachine/version.rb
|
175
|
+
- integrations/observed-eventmachine/observed-eventmachine.gemspec
|
164
176
|
- lib/observed.rb
|
165
177
|
- lib/observed/application.rb
|
166
178
|
- lib/observed/application/oneshot.rb
|
@@ -171,23 +183,39 @@ files:
|
|
171
183
|
- lib/observed/config_builder.rb
|
172
184
|
- lib/observed/config_dsl.rb
|
173
185
|
- lib/observed/configurable.rb
|
186
|
+
- lib/observed/context.rb
|
174
187
|
- lib/observed/default.rb
|
175
188
|
- lib/observed/default/observer.rb
|
176
|
-
- lib/observed/
|
189
|
+
- lib/observed/event_bus.rb
|
190
|
+
- lib/observed/execution_job_factory.rb
|
177
191
|
- lib/observed/hash.rb
|
178
192
|
- lib/observed/hash/builder.rb
|
179
193
|
- lib/observed/hash/fetcher.rb
|
180
194
|
- lib/observed/hash/key_path_encoding.rb
|
195
|
+
- lib/observed/job.rb
|
196
|
+
- lib/observed/jobbed_event_bus.rb
|
197
|
+
- lib/observed/logging.rb
|
181
198
|
- lib/observed/observer.rb
|
182
199
|
- lib/observed/observer_helpers/timer.rb
|
183
200
|
- lib/observed/pluggable.rb
|
184
|
-
- lib/observed/reader.rb
|
185
201
|
- lib/observed/reporter.rb
|
186
202
|
- lib/observed/reporter/regexp_matching.rb
|
203
|
+
- lib/observed/reporter/report_formatting.rb
|
187
204
|
- lib/observed/system.rb
|
205
|
+
- lib/observed/translator.rb
|
188
206
|
- lib/observed/version.rb
|
189
|
-
- lib/observed/writer.rb
|
190
207
|
- observed.gemspec
|
208
|
+
- omnibus-observed/.gitignore
|
209
|
+
- omnibus-observed/Berksfile
|
210
|
+
- omnibus-observed/Berksfile.lock
|
211
|
+
- omnibus-observed/Gemfile
|
212
|
+
- omnibus-observed/README.md
|
213
|
+
- omnibus-observed/Vagrantfile
|
214
|
+
- omnibus-observed/config/projects/observed.rb
|
215
|
+
- omnibus-observed/config/software/observed.rb
|
216
|
+
- omnibus-observed/package-scripts/observed/makeselfinst
|
217
|
+
- omnibus-observed/package-scripts/observed/postinst
|
218
|
+
- omnibus-observed/package-scripts/observed/postrm
|
191
219
|
- plugins/observed-fluentd/.gitignore
|
192
220
|
- plugins/observed-fluentd/Gemfile
|
193
221
|
- plugins/observed-fluentd/LICENSE.txt
|
@@ -212,6 +240,8 @@ files:
|
|
212
240
|
- plugins/observed-gauge/observed-gauge.gemspec
|
213
241
|
- plugins/observed-gauge/spec/gauge_spec.rb
|
214
242
|
- plugins/observed-gauge/spec/spec_helper.rb
|
243
|
+
- plugins/observed-growl/Gemfile
|
244
|
+
- plugins/observed-growl/lib/observed/growl.rb
|
215
245
|
- plugins/observed-http/.gitignore
|
216
246
|
- plugins/observed-http/Gemfile
|
217
247
|
- plugins/observed-http/LICENSE.txt
|
@@ -224,12 +254,18 @@ files:
|
|
224
254
|
- plugins/observed-http/observed-http.gemspec
|
225
255
|
- plugins/observed-http/spec/fixtures/observed.conf
|
226
256
|
- plugins/observed-http/spec/http_spec.rb
|
257
|
+
- plugins/observed-http/spec/integration_spec.rb
|
227
258
|
- plugins/observed-http/spec/spec_helper.rb
|
259
|
+
- plugins/observed-shell/Gemfile
|
260
|
+
- plugins/observed-shell/lib/observed/shell.rb
|
261
|
+
- run-integration-tests
|
228
262
|
- spec/builtin_plugins/file_spec.rb
|
229
263
|
- spec/builtin_plugins/stdout_spec.rb
|
230
264
|
- spec/config_builder_spec.rb
|
231
265
|
- spec/config_dsl_spec.rb
|
232
266
|
- spec/configurable_spec.rb
|
267
|
+
- spec/event_bus_spec.rb
|
268
|
+
- spec/execution_job_factory_spec.rb
|
233
269
|
- spec/fixtures/configure_by_conf/foo_plugin.rb
|
234
270
|
- spec/fixtures/configure_by_conf/observed.conf
|
235
271
|
- spec/fixtures/configure_by_conf_dot_d/foo_plugin.rb
|
@@ -239,14 +275,16 @@ files:
|
|
239
275
|
- spec/hash/builder_spec.rb
|
240
276
|
- spec/hash/fetcher_spec.rb
|
241
277
|
- spec/input_helpers/timer_spec.rb
|
278
|
+
- spec/job_factory_spec.rb
|
279
|
+
- spec/job_spec.rb
|
280
|
+
- spec/jobbed_event_bus_spec.rb
|
242
281
|
- spec/observed_spec.rb
|
282
|
+
- spec/observer_helpers/timer_spec.rb
|
243
283
|
- spec/observer_spec.rb
|
244
284
|
- spec/oneshot_spec.rb
|
245
|
-
- spec/reader_spec.rb
|
246
285
|
- spec/reporter_spec.rb
|
247
286
|
- spec/spec_helper.rb
|
248
287
|
- spec/system_spec.rb
|
249
|
-
- spec/writer_spec.rb
|
250
288
|
homepage: ''
|
251
289
|
licenses:
|
252
290
|
- MIT
|
@@ -262,16 +300,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
300
|
version: '0'
|
263
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
302
|
requirements:
|
265
|
-
- - ! '
|
303
|
+
- - ! '>'
|
266
304
|
- !ruby/object:Gem::Version
|
267
|
-
version:
|
305
|
+
version: 1.3.1
|
268
306
|
requirements: []
|
269
307
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
308
|
+
rubygems_version: 2.1.10
|
271
309
|
signing_key:
|
272
310
|
specification_version: 4
|
273
311
|
summary: Observed is a health-check framework for various services
|
274
312
|
test_files:
|
313
|
+
- features/explicit_routing.feature
|
275
314
|
- features/oneshot.feature
|
276
315
|
- features/support/env.rb
|
277
316
|
- features/test_in_single_ruby_source.feature
|
@@ -280,6 +319,8 @@ test_files:
|
|
280
319
|
- spec/config_builder_spec.rb
|
281
320
|
- spec/config_dsl_spec.rb
|
282
321
|
- spec/configurable_spec.rb
|
322
|
+
- spec/event_bus_spec.rb
|
323
|
+
- spec/execution_job_factory_spec.rb
|
283
324
|
- spec/fixtures/configure_by_conf/foo_plugin.rb
|
284
325
|
- spec/fixtures/configure_by_conf/observed.conf
|
285
326
|
- spec/fixtures/configure_by_conf_dot_d/foo_plugin.rb
|
@@ -289,11 +330,13 @@ test_files:
|
|
289
330
|
- spec/hash/builder_spec.rb
|
290
331
|
- spec/hash/fetcher_spec.rb
|
291
332
|
- spec/input_helpers/timer_spec.rb
|
333
|
+
- spec/job_factory_spec.rb
|
334
|
+
- spec/job_spec.rb
|
335
|
+
- spec/jobbed_event_bus_spec.rb
|
292
336
|
- spec/observed_spec.rb
|
337
|
+
- spec/observer_helpers/timer_spec.rb
|
293
338
|
- spec/observer_spec.rb
|
294
339
|
- spec/oneshot_spec.rb
|
295
|
-
- spec/reader_spec.rb
|
296
340
|
- spec/reporter_spec.rb
|
297
341
|
- spec/spec_helper.rb
|
298
342
|
- spec/system_spec.rb
|
299
|
-
- spec/writer_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'observed/reporter'
|
2
|
-
require 'observed/reporter/regexp_matching'
|
3
|
-
|
4
|
-
module Observed
|
5
|
-
module Default
|
6
|
-
class Reporter < Observed::Reporter
|
7
|
-
include Observed::Reporter::RegexpMatching
|
8
|
-
|
9
|
-
attribute :writer
|
10
|
-
|
11
|
-
def report(tag, time, data)
|
12
|
-
writer.write tag, time, data
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/observed/reader.rb
DELETED
data/lib/observed/writer.rb
DELETED