govuk_app_config 3.0.0 → 4.0.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -0
- data/CHANGELOG.md +23 -0
- data/README.md +3 -3
- data/govuk_app_config.gemspec +5 -4
- data/lib/govuk_app_config/govuk_error.rb +4 -3
- data/lib/govuk_app_config/govuk_error/configuration.rb +34 -19
- data/lib/govuk_app_config/govuk_error/configure.rb +2 -10
- data/lib/govuk_app_config/govuk_error/govuk_data_sync.rb +1 -7
- data/lib/govuk_app_config/version.rb +1 -1
- metadata +24 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64e3b5e80cdc107dd26911c7bf2cf9e298fe37fbb7b7cc28b3c860f74424843e
|
4
|
+
data.tar.gz: 45051a0d49d02e14b1385894ac53f61ebdaffa11f9379c6f2ac7c1c5752d0794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ac4913c546cbf10958b1efca95792886bb4d2dac81aa4303bea4343515d23fabedc94e272a5aa6383cff6c27448d4bcd8ceda27d4329f7be3dbb651f86ca79
|
7
|
+
data.tar.gz: aee0bd0ff3a81e6ade12461b81a10073c903eb7c35762f744c89d4feec0fe5f933bcb20609e75add6b94d8e60c0c49d836527517c8defcdcc3ee23856143be02
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 4.0.0.pre.3
|
2
|
+
|
3
|
+
- Include [sentry-rails](https://github.com/getsentry/sentry-ruby/tree/master/sentry-rails) by default ([#203](https://github.com/alphagov/govuk_app_config/pull/203)).
|
4
|
+
|
5
|
+
# 4.0.0.pre.2
|
6
|
+
|
7
|
+
- Fix default Sentry configuration ([#202](https://github.com/alphagov/govuk_app_config/pull/202)).
|
8
|
+
- BREAKING: this means no more `silence_ready` or `transport_failure_callback` options.
|
9
|
+
|
10
|
+
# 4.0.0.pre.1
|
11
|
+
|
12
|
+
- BREAKING: upgrades Sentry gem from `sentry-raven` to `sentry-ruby` ([#199](https://github.com/alphagov/govuk_app_config/pull/199)). There is a **[migration guide](https://docs.sentry.io/platforms/ruby/migration/)** you should follow before upgrading to this version of govuk_app_config.
|
13
|
+
- This release also fixes the `data_sync_excluded_exceptions` behaviour that has been broken since v3.1.0.
|
14
|
+
- Released as a pre-release to identify and fix any problems before a wider rollout.
|
15
|
+
|
16
|
+
# 3.1.1
|
17
|
+
|
18
|
+
- Fix the new before_send behaviour & tests, and add documentation ([#197](https://github.com/alphagov/govuk_app_config/pull/197))
|
19
|
+
|
20
|
+
# 3.1.0
|
21
|
+
|
22
|
+
- Remove support for `should_capture` callbacks in favour of `before_send` ([#196](https://github.com/alphagov/govuk_app_config/pull/196))
|
23
|
+
|
1
24
|
# 3.0.0
|
2
25
|
|
3
26
|
* BREAKING: Implement RFC 141 - remove unsuitable healthchecks and return a 500 on healthcheck failure ([#193](https://github.com/alphagov/govuk_app_config/pull/193))
|
data/README.md
CHANGED
@@ -112,12 +112,12 @@ end
|
|
112
112
|
Finally, you can pass your own callback to evaluate whether or not to capture the exception.
|
113
113
|
Note that if an exception is on the `excluded_exceptions` list, or on the `data_sync_excluded_exceptions`
|
114
114
|
and occurs at the time of a data sync, then it will be excluded even if the custom
|
115
|
-
`
|
115
|
+
`before_send` callback doesn't return `nil`.
|
116
116
|
|
117
117
|
```ruby
|
118
118
|
GovukError.configure do |config|
|
119
|
-
config.
|
120
|
-
|
119
|
+
config.before_send = lambda do |event, hint|
|
120
|
+
hint[:exception].is_a?(ErrorWeWantToIgnore) ? nil : event
|
121
121
|
end
|
122
122
|
end
|
123
123
|
```
|
data/govuk_app_config.gemspec
CHANGED
@@ -13,15 +13,16 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/alphagov/govuk_app_config"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.
|
17
|
-
|
18
|
-
|
16
|
+
spec.required_ruby_version = ">= 2.6"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
19
|
spec.bindir = "exe"
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = %w[lib]
|
22
22
|
|
23
23
|
spec.add_dependency "logstasher", ">= 1.2.2", "< 2.2.0"
|
24
|
-
spec.add_dependency "sentry-
|
24
|
+
spec.add_dependency "sentry-rails", "~> 4.5.0"
|
25
|
+
spec.add_dependency "sentry-ruby", "~> 4.5.0"
|
25
26
|
spec.add_dependency "statsd-ruby", "~> 1.5.0"
|
26
27
|
spec.add_dependency "unicorn", ">= 5.4", "< 5.9"
|
27
28
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require "sentry-
|
1
|
+
require "sentry-ruby"
|
2
|
+
require "sentry-rails"
|
2
3
|
require "govuk_app_config/govuk_statsd"
|
3
4
|
require "govuk_app_config/govuk_error/configuration"
|
4
5
|
require "govuk_app_config/version"
|
@@ -13,11 +14,11 @@ module GovukError
|
|
13
14
|
args[:tags] ||= {}
|
14
15
|
args[:tags][:govuk_app_config_version] = GovukAppConfig::VERSION
|
15
16
|
|
16
|
-
|
17
|
+
Sentry.capture_exception(exception_or_message, args)
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.configure
|
20
|
-
@configuration ||= Configuration.new(
|
21
|
+
@configuration ||= Configuration.new(Sentry::Configuration.new)
|
21
22
|
yield @configuration
|
22
23
|
end
|
23
24
|
end
|
@@ -6,41 +6,35 @@ module GovukError
|
|
6
6
|
attr_reader :data_sync, :sentry_environment
|
7
7
|
attr_accessor :active_sentry_environments, :data_sync_excluded_exceptions
|
8
8
|
|
9
|
-
def initialize(
|
9
|
+
def initialize(_sentry_configuration)
|
10
10
|
super
|
11
11
|
@sentry_environment = ENV["SENTRY_CURRENT_ENV"]
|
12
12
|
@data_sync = GovukDataSync.new(ENV["GOVUK_DATA_SYNC_PERIOD"])
|
13
13
|
self.active_sentry_environments = []
|
14
14
|
self.data_sync_excluded_exceptions = []
|
15
|
-
|
15
|
+
@before_send_callbacks = [
|
16
|
+
ignore_exceptions_if_not_in_active_sentry_env,
|
17
|
+
ignore_excluded_exceptions_in_data_sync,
|
18
|
+
increment_govuk_statsd_counters,
|
19
|
+
]
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
super(combined)
|
22
|
+
def before_send=(closure)
|
23
|
+
@before_send_callbacks.insert(-2, closure)
|
24
|
+
super(run_before_send_callbacks)
|
24
25
|
end
|
25
26
|
|
26
27
|
protected
|
27
28
|
|
28
|
-
def ignore_exceptions_based_on_env_and_data_sync
|
29
|
-
lambda do |error_or_event|
|
30
|
-
ignore_exceptions_if_not_in_active_sentry_env.call(error_or_event) &&
|
31
|
-
ignore_excluded_exceptions_in_data_sync.call(error_or_event)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
29
|
def ignore_exceptions_if_not_in_active_sentry_env
|
36
|
-
->(
|
30
|
+
->(event, _hint) { event if active_sentry_environments.include?(sentry_environment) }
|
37
31
|
end
|
38
32
|
|
39
33
|
def ignore_excluded_exceptions_in_data_sync
|
40
|
-
lambda { |
|
34
|
+
lambda { |event, hint|
|
41
35
|
data_sync_ignored_error = data_sync_excluded_exceptions.any? do |exception_to_ignore|
|
42
36
|
exception_to_ignore = Object.const_get(exception_to_ignore) unless exception_to_ignore.is_a?(Module)
|
43
|
-
exception_chain =
|
37
|
+
exception_chain = Sentry::Utils::ExceptionCauseChain.exception_to_array(hint[:exception])
|
44
38
|
exception_chain.any? { |exception| exception.is_a?(exception_to_ignore) }
|
45
39
|
rescue NameError
|
46
40
|
# the exception type represented by the exception_to_ignore string
|
@@ -48,8 +42,29 @@ module GovukError
|
|
48
42
|
false
|
49
43
|
end
|
50
44
|
|
51
|
-
|
45
|
+
event unless data_sync.in_progress? && data_sync_ignored_error
|
52
46
|
}
|
53
47
|
end
|
48
|
+
|
49
|
+
def increment_govuk_statsd_counters
|
50
|
+
lambda { |event, hint|
|
51
|
+
if hint[:exception]
|
52
|
+
GovukStatsd.increment("errors_occurred")
|
53
|
+
GovukStatsd.increment("error_types.#{hint[:exception].class.name.split('::').last.underscore}")
|
54
|
+
end
|
55
|
+
event
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def run_before_send_callbacks
|
60
|
+
lambda do |event, hint|
|
61
|
+
result = event
|
62
|
+
@before_send_callbacks.each do |callback|
|
63
|
+
result = callback.call(event, hint)
|
64
|
+
break if result.nil?
|
65
|
+
end
|
66
|
+
result
|
67
|
+
end
|
68
|
+
end
|
54
69
|
end
|
55
70
|
end
|
@@ -1,12 +1,4 @@
|
|
1
1
|
GovukError.configure do |config|
|
2
|
-
config.before_send = proc { |e|
|
3
|
-
GovukStatsd.increment("errors_occurred")
|
4
|
-
GovukStatsd.increment("error_types.#{e.class.name.demodulize.underscore}")
|
5
|
-
e
|
6
|
-
}
|
7
|
-
|
8
|
-
config.silence_ready = !Rails.env.production? if defined?(Rails)
|
9
|
-
|
10
2
|
# These are the environments (described by the `SENTRY_CURRENT_ENV`
|
11
3
|
# ENV variable) where we want to capture Sentry errors. If
|
12
4
|
# `SENTRY_CURRENT_ENV` isn't in this list, or isn't defined, then
|
@@ -64,7 +56,7 @@ GovukError.configure do |config|
|
|
64
56
|
"GdsApi::ContentStore::ItemNotFound",
|
65
57
|
]
|
66
58
|
|
67
|
-
config.
|
68
|
-
|
59
|
+
config.before_send = lambda { |error_or_event, _hint|
|
60
|
+
error_or_event
|
69
61
|
}
|
70
62
|
end
|
@@ -3,14 +3,8 @@ require "time"
|
|
3
3
|
module GovukError
|
4
4
|
class GovukDataSync
|
5
5
|
class MalformedDataSyncPeriod < RuntimeError
|
6
|
-
attr_reader :invalid_value
|
7
|
-
|
8
6
|
def initialize(invalid_value)
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def message
|
13
|
-
"\"#{invalid_value}\" is not a valid value (should be of form '22:00-03:00')."
|
7
|
+
super("\"#{invalid_value}\" is not a valid value (should be of form '22:00-03:00').")
|
14
8
|
end
|
15
9
|
end
|
16
10
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_app_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstasher
|
@@ -31,19 +31,33 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: sentry-
|
34
|
+
name: sentry-rails
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 4.5.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 4.5.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sentry-ruby
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 4.5.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 4.5.0
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: statsd-ruby
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,6 +225,7 @@ executables: []
|
|
211
225
|
extensions: []
|
212
226
|
extra_rdoc_files: []
|
213
227
|
files:
|
228
|
+
- ".github/dependabot.yml"
|
214
229
|
- ".gitignore"
|
215
230
|
- ".rspec"
|
216
231
|
- ".rubocop.yml"
|
@@ -257,14 +272,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
257
272
|
requirements:
|
258
273
|
- - ">="
|
259
274
|
- !ruby/object:Gem::Version
|
260
|
-
version: '
|
275
|
+
version: '2.6'
|
261
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
277
|
requirements:
|
263
|
-
- - "
|
278
|
+
- - ">"
|
264
279
|
- !ruby/object:Gem::Version
|
265
|
-
version:
|
280
|
+
version: 1.3.1
|
266
281
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
282
|
+
rubygems_version: 3.0.3
|
268
283
|
signing_key:
|
269
284
|
specification_version: 4
|
270
285
|
summary: Base configuration for GOV.UK applications
|