stoplight 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +35 -1
- data/lib/stoplight.rb +2 -0
- data/lib/stoplight/notifier/pagerduty.rb +21 -0
- data/lib/stoplight/notifier/rollbar.rb +39 -0
- data/lib/stoplight/version.rb +1 -1
- data/spec/stoplight/default_spec.rb +1 -1
- data/spec/stoplight/notifier/bugsnag_spec.rb +1 -3
- data/spec/stoplight/notifier/pagerduty_spec.rb +40 -0
- data/spec/stoplight/notifier/rollbar_spec.rb +90 -0
- metadata +26 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b66bb764bd763618206249ec2f6942377ccdd3d9f61dd98c96ddfa27f4020c63
|
4
|
+
data.tar.gz: a0b78e0231f0ae7cd15a41ac749ebb4bccec204ca25475cc780b6d45a2dc6f5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95050e149634a50373a73a62a7de560fc2beb97e0dede532dbeb25b45e09c887655e20454604bb3b07c7b4306a13f5b819459c5f1ec03807f1a13d7ed2fc772b
|
7
|
+
data.tar.gz: 98753fc93435db4bd0b8626e85e84ed37c25e8e4fef5e9cf40d608f24a3c5c4a49b3add526fa0eb918964f949f0087c78c052eec3af9a3e5e18ae93194ee4c4a
|
data/README.md
CHANGED
@@ -32,6 +32,8 @@ Check out [stoplight-admin][] for controlling your stoplights.
|
|
32
32
|
- [HipChat](#hipchat)
|
33
33
|
- [Honeybadger](#honeybadger)
|
34
34
|
- [Logger](#logger)
|
35
|
+
- [Pagerduty](#pagerduty)
|
36
|
+
- [Rollbar](#rollbar)
|
35
37
|
- [Sentry](#sentry)
|
36
38
|
- [Slack](#slack)
|
37
39
|
- [Rails](#rails-1)
|
@@ -204,7 +206,7 @@ The default threshold is `3`.
|
|
204
206
|
### Custom cool off time
|
205
207
|
|
206
208
|
Stoplights will automatically attempt to recover after a certain amount of
|
207
|
-
time. A light in the red state for longer than the cool
|
209
|
+
time. A light in the red state for longer than the cool off period will
|
208
210
|
transition to the yellow state. This cool off time is customizable.
|
209
211
|
|
210
212
|
``` rb
|
@@ -356,6 +358,36 @@ Stoplight::Light.default_notifiers += [notifier]
|
|
356
358
|
# => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Notifier::Logger:...>]
|
357
359
|
```
|
358
360
|
|
361
|
+
#### Pagerduty
|
362
|
+
|
363
|
+
Make sure you have [the Pagerduty gem][] (`~> 2.1`) installed before configuring
|
364
|
+
Stoplight.
|
365
|
+
|
366
|
+
``` rb
|
367
|
+
require 'pagerduty'
|
368
|
+
# => true
|
369
|
+
pagerduty = Pagerduty.new('http://www.example.com/webhook-url')
|
370
|
+
# => #<Pagerduty:...>
|
371
|
+
notifier = Stoplight::Notifier::Pagerduty.new(pagerduty)
|
372
|
+
# => #<Stoplight::Notifier::Pagerduty:...>
|
373
|
+
Stoplight::Light.default_notifiers += [notifier]
|
374
|
+
# => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Notifier::Pagerduty:...>]
|
375
|
+
```
|
376
|
+
|
377
|
+
#### Rollbar
|
378
|
+
|
379
|
+
Make sure you have [the Rollbar gem][] (`~> 2.0`) installed before configuring
|
380
|
+
Stoplight.
|
381
|
+
|
382
|
+
``` rb
|
383
|
+
require 'rollbar'
|
384
|
+
# => true
|
385
|
+
notifier = Stoplight::Notifier::Rollbar.new(Rollbar)
|
386
|
+
# => #<Stoplight::Notifier::Rollbar:...>
|
387
|
+
Stoplight::Light.default_notifiers += [notifier]
|
388
|
+
# => [#<Stoplight::Notifier::IO:...>, #<Stoplight::Notifier::Rollbar:...>]
|
389
|
+
```
|
390
|
+
|
359
391
|
#### Sentry
|
360
392
|
|
361
393
|
Make sure you have [the Sentry gem][] (`~> 1.2`) installed before configuring
|
@@ -490,8 +522,10 @@ Stoplight is licensed under [the MIT License][].
|
|
490
522
|
[the HipChat gem]: https://rubygems.org/gems/hipchat
|
491
523
|
[the Honeybadger gem]: https://rubygems.org/gems/honeybadger
|
492
524
|
[the Logger class]: http://ruby-doc.org/stdlib-2.2.3/libdoc/logger/rdoc/Logger.html
|
525
|
+
[the Rollbar gem]: https://rubygems.org/gems/rollbar
|
493
526
|
[the Sentry gem]: https://rubygems.org/gems/sentry-raven
|
494
527
|
[the Slack gem]: https://rubygems.org/gems/slack-notifier
|
528
|
+
[the Pagerduty gem]: https://rubygems.org/gems/pagerduty
|
495
529
|
[@camdez]: https://github.com/camdez
|
496
530
|
[@tfausak]: https://github.com/tfausak
|
497
531
|
[@orgsync]: https://github.com/OrgSync
|
data/lib/stoplight.rb
CHANGED
@@ -24,7 +24,9 @@ require 'stoplight/notifier/hip_chat'
|
|
24
24
|
require 'stoplight/notifier/honeybadger'
|
25
25
|
require 'stoplight/notifier/io'
|
26
26
|
require 'stoplight/notifier/logger'
|
27
|
+
require 'stoplight/notifier/pagerduty'
|
27
28
|
require 'stoplight/notifier/raven'
|
29
|
+
require 'stoplight/notifier/rollbar'
|
28
30
|
require 'stoplight/notifier/slack'
|
29
31
|
|
30
32
|
require 'stoplight/default'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Stoplight
|
4
|
+
module Notifier
|
5
|
+
# @see Base
|
6
|
+
class Pagerduty < Base
|
7
|
+
include Generic
|
8
|
+
|
9
|
+
# @return [::Pagerduty]
|
10
|
+
def pagerduty
|
11
|
+
@object
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def put(message)
|
17
|
+
pagerduty.trigger(message)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Stoplight
|
4
|
+
module Notifier
|
5
|
+
# @see Base
|
6
|
+
class Rollbar < Base
|
7
|
+
DEFAULT_OPTIONS = {
|
8
|
+
severity: 'info'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
StoplightStatusChange = Class.new(Error::Base)
|
12
|
+
|
13
|
+
# @return [Proc]
|
14
|
+
attr_reader :formatter
|
15
|
+
# @return [::Rollbar]
|
16
|
+
attr_reader :rollbar
|
17
|
+
# @return [Hash{Symbol => Object}]
|
18
|
+
attr_reader :options
|
19
|
+
|
20
|
+
# @param rollbar [::Rollbar]
|
21
|
+
# @param formatter [Proc, nil]
|
22
|
+
# @param options [Hash{Symbol => Object}]
|
23
|
+
# @option options [String] :severity
|
24
|
+
def initialize(rollbar, formatter = nil, options = {})
|
25
|
+
@rollbar = rollbar
|
26
|
+
@formatter = formatter || Default::FORMATTER
|
27
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def notify(light, from_color, to_color, error)
|
31
|
+
formatter.call(light, from_color, to_color, error).tap do |message|
|
32
|
+
severity = options.fetch(:severity)
|
33
|
+
exception = StoplightStatusChange.new(message)
|
34
|
+
rollbar.__send__(severity, exception)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/stoplight/version.rb
CHANGED
@@ -7,8 +7,6 @@ module Bugsnag
|
|
7
7
|
end
|
8
8
|
|
9
9
|
RSpec.describe Stoplight::Notifier::Bugsnag do
|
10
|
-
StoplightStatusChange = Stoplight::Notifier::Bugsnag::StoplightStatusChange
|
11
|
-
|
12
10
|
it 'is a class' do
|
13
11
|
expect(described_class).to be_a(Class)
|
14
12
|
end
|
@@ -65,7 +63,7 @@ RSpec.describe Stoplight::Notifier::Bugsnag do
|
|
65
63
|
end
|
66
64
|
|
67
65
|
before do
|
68
|
-
status_change = StoplightStatusChange.new(message)
|
66
|
+
status_change = described_class::StoplightStatusChange.new(message)
|
69
67
|
expect(bugsnag).to receive(:notify).with(status_change, severity: 'info')
|
70
68
|
end
|
71
69
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'pagerduty'
|
5
|
+
|
6
|
+
RSpec.describe Stoplight::Notifier::Pagerduty do
|
7
|
+
it_behaves_like 'a generic notifier'
|
8
|
+
|
9
|
+
it 'is a class' do
|
10
|
+
expect(described_class).to be_a(Class)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'is a subclass of Base' do
|
14
|
+
expect(described_class).to be < Stoplight::Notifier::Base
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#pagerduty' do
|
18
|
+
it 'reads Pagerduty client' do
|
19
|
+
pagerduty = Pagerduty.new('WEBHOOK_URL')
|
20
|
+
expect(described_class.new(pagerduty).pagerduty).to eql(pagerduty)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#notify' do
|
25
|
+
let(:light) { Stoplight::Light.new(name, &code) }
|
26
|
+
let(:name) { ('a'..'z').to_a.shuffle.join }
|
27
|
+
let(:code) { -> {} }
|
28
|
+
let(:from_color) { Stoplight::Color::GREEN }
|
29
|
+
let(:to_color) { Stoplight::Color::RED }
|
30
|
+
let(:notifier) { described_class.new(pagerduty) }
|
31
|
+
let(:pagerduty) { double(Pagerduty).as_null_object }
|
32
|
+
|
33
|
+
it 'pings Pagerduty' do
|
34
|
+
error = nil
|
35
|
+
message = notifier.formatter.call(light, from_color, to_color, error)
|
36
|
+
expect(pagerduty).to receive(:trigger).with(message)
|
37
|
+
notifier.notify(light, from_color, to_color, error)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
# require 'rollbar'
|
6
|
+
module Rollbar
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe Stoplight::Notifier::Rollbar do
|
10
|
+
it 'is a class' do
|
11
|
+
expect(described_class).to be_a(Class)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is a subclass of Base' do
|
15
|
+
expect(described_class).to be < Stoplight::Notifier::Base
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#formatter' do
|
19
|
+
it 'is initially the default' do
|
20
|
+
expect(described_class.new(nil, nil).formatter)
|
21
|
+
.to eql(Stoplight::Default::FORMATTER)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'reads the formatter' do
|
25
|
+
formatter = proc {}
|
26
|
+
expect(described_class.new(nil, formatter).formatter)
|
27
|
+
.to eql(formatter)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#options' do
|
32
|
+
it 'is initially the default' do
|
33
|
+
expect(described_class.new(nil, nil).options)
|
34
|
+
.to eql(Stoplight::Notifier::Rollbar::DEFAULT_OPTIONS)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'reads the options' do
|
38
|
+
options = { key: :value }
|
39
|
+
expect(described_class.new(nil, nil, options).options)
|
40
|
+
.to eql(Stoplight::Notifier::Rollbar::DEFAULT_OPTIONS.merge(options))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#rollbar' do
|
45
|
+
it 'reads the Rollbar client' do
|
46
|
+
client = Rollbar
|
47
|
+
expect(described_class.new(client, nil).rollbar)
|
48
|
+
.to eql(client)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#notify' do
|
53
|
+
let(:light) { Stoplight::Light.new(name, &code) }
|
54
|
+
let(:name) { ('a'..'z').to_a.shuffle.join }
|
55
|
+
let(:code) { -> {} }
|
56
|
+
let(:from_color) { Stoplight::Color::GREEN }
|
57
|
+
let(:to_color) { Stoplight::Color::RED }
|
58
|
+
let(:notifier) { described_class.new(rollbar) }
|
59
|
+
let(:rollbar) { Rollbar }
|
60
|
+
|
61
|
+
subject(:result) do
|
62
|
+
notifier.notify(light, from_color, to_color, error)
|
63
|
+
end
|
64
|
+
|
65
|
+
before do
|
66
|
+
status_change = described_class::StoplightStatusChange.new(message)
|
67
|
+
expect(rollbar).to receive(:info).with(status_change)
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when no error given' do
|
71
|
+
let(:error) { nil }
|
72
|
+
|
73
|
+
it 'logs message' do
|
74
|
+
expect(result).to eq(message)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when message with an error given' do
|
79
|
+
let(:error) { ZeroDivisionError.new('divided by 0') }
|
80
|
+
|
81
|
+
it 'logs message' do
|
82
|
+
expect(result).to eq(message)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def message
|
87
|
+
notifier.formatter.call(light, from_color, to_color, error)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stoplight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Desautels
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: benchmark-ips
|
@@ -97,19 +97,19 @@ dependencies:
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '2.5'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
100
|
+
name: pagerduty
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 2.1.1
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 2.1.1
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rake
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,6 +166,20 @@ dependencies:
|
|
166
166
|
- - "~>"
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: 0.40.0
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: sentry-raven
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - "~>"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '1.2'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '1.2'
|
169
183
|
- !ruby/object:Gem::Dependency
|
170
184
|
name: slack-notifier
|
171
185
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,7 +239,9 @@ files:
|
|
225
239
|
- lib/stoplight/notifier/honeybadger.rb
|
226
240
|
- lib/stoplight/notifier/io.rb
|
227
241
|
- lib/stoplight/notifier/logger.rb
|
242
|
+
- lib/stoplight/notifier/pagerduty.rb
|
228
243
|
- lib/stoplight/notifier/raven.rb
|
244
|
+
- lib/stoplight/notifier/rollbar.rb
|
229
245
|
- lib/stoplight/notifier/slack.rb
|
230
246
|
- lib/stoplight/state.rb
|
231
247
|
- lib/stoplight/version.rb
|
@@ -247,7 +263,9 @@ files:
|
|
247
263
|
- spec/stoplight/notifier/honeybadger_spec.rb
|
248
264
|
- spec/stoplight/notifier/io_spec.rb
|
249
265
|
- spec/stoplight/notifier/logger_spec.rb
|
266
|
+
- spec/stoplight/notifier/pagerduty_spec.rb
|
250
267
|
- spec/stoplight/notifier/raven_spec.rb
|
268
|
+
- spec/stoplight/notifier/rollbar_spec.rb
|
251
269
|
- spec/stoplight/notifier/slack_spec.rb
|
252
270
|
- spec/stoplight/notifier_spec.rb
|
253
271
|
- spec/stoplight/state_spec.rb
|
@@ -272,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
290
|
- !ruby/object:Gem::Version
|
273
291
|
version: '0'
|
274
292
|
requirements: []
|
275
|
-
|
276
|
-
rubygems_version: 2.5.2
|
293
|
+
rubygems_version: 3.0.3
|
277
294
|
signing_key:
|
278
295
|
specification_version: 4
|
279
296
|
summary: Traffic control for code.
|
@@ -282,12 +299,14 @@ test_files:
|
|
282
299
|
- spec/stoplight_spec.rb
|
283
300
|
- spec/stoplight/error_spec.rb
|
284
301
|
- spec/stoplight/failure_spec.rb
|
302
|
+
- spec/stoplight/notifier/pagerduty_spec.rb
|
285
303
|
- spec/stoplight/notifier/raven_spec.rb
|
286
304
|
- spec/stoplight/notifier/io_spec.rb
|
287
305
|
- spec/stoplight/notifier/logger_spec.rb
|
288
306
|
- spec/stoplight/notifier/honeybadger_spec.rb
|
289
307
|
- spec/stoplight/notifier/generic_spec.rb
|
290
308
|
- spec/stoplight/notifier/slack_spec.rb
|
309
|
+
- spec/stoplight/notifier/rollbar_spec.rb
|
291
310
|
- spec/stoplight/notifier/base_spec.rb
|
292
311
|
- spec/stoplight/notifier/bugsnag_spec.rb
|
293
312
|
- spec/stoplight/notifier/hip_chat_spec.rb
|