govuk_app_config 4.0.0.pre.3 → 4.0.0.pre.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/govuk_app_config.rb +0 -1
- data/lib/govuk_app_config/govuk_error.rb +21 -3
- data/lib/govuk_app_config/govuk_error/configuration.rb +68 -10
- data/lib/govuk_app_config/railtie.rb +4 -0
- data/lib/govuk_app_config/version.rb +1 -1
- metadata +2 -3
- data/lib/govuk_app_config/govuk_error/configure.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 494d23c9b999e7cfd6a7e2fac76f1a52cdf70aa5b7c62509e48693c13bb07d7c
|
4
|
+
data.tar.gz: ccd962b2f670063ead978e49f38affcf925b1e05a47b4a97066b88b5243dcbaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 624aefd37a2c76460bfecdbf17071991fa3745249ac27b9bb6026bc67e4e335cd94bdf67d82f8521557c8661fca36ced879a68a346bfe592786e88df0f06ddbe
|
7
|
+
data.tar.gz: 7cbbc37819f1b176dde9d4d90bf71b333621cdfabfd042b2fe439223aa47a98c43713b86f2784c6ced2c43a9f28cb01bf83f021e724de7def9e4a7a74dd0c264
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 4.0.0.pre.4
|
2
|
+
|
3
|
+
- Fix Sentry client initialisation ([#205](https://github.com/alphagov/govuk_app_config/pull/205)).
|
4
|
+
- BREAKING: non-Rails apps will need to manually call `GovukError.configure` in order to initialise Sentry.
|
5
|
+
- BREAKING: `GovukError.configure` can only be called once by the downstream application.
|
6
|
+
|
1
7
|
# 4.0.0.pre.3
|
2
8
|
|
3
9
|
- 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)).
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ You can add your environment to the list of active Sentry environments like so:
|
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
GovukError.configure do |config|
|
90
|
-
config.
|
90
|
+
config.enabled_environments << "my-test-environment"
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
data/lib/govuk_app_config.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "govuk_app_config/version"
|
2
2
|
require "govuk_app_config/govuk_statsd"
|
3
3
|
require "govuk_app_config/govuk_error"
|
4
|
-
require "govuk_app_config/govuk_error/configure"
|
5
4
|
require "govuk_app_config/govuk_healthcheck"
|
6
5
|
require "govuk_app_config/govuk_i18n"
|
7
6
|
# This require is deprecated and should be removed on next major version bump
|
@@ -5,6 +5,12 @@ require "govuk_app_config/govuk_error/configuration"
|
|
5
5
|
require "govuk_app_config/version"
|
6
6
|
|
7
7
|
module GovukError
|
8
|
+
class AlreadyInitialised < StandardError
|
9
|
+
def initialize(msg = "You can only call GovukError.configure once!")
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
def self.notify(exception_or_message, args = {})
|
9
15
|
# Allow users to use `parameters` as a key like the Airbrake
|
10
16
|
# client, allowing easy upgrades.
|
@@ -14,11 +20,23 @@ module GovukError
|
|
14
20
|
args[:tags] ||= {}
|
15
21
|
args[:tags][:govuk_app_config_version] = GovukAppConfig::VERSION
|
16
22
|
|
17
|
-
|
23
|
+
if exception_or_message.is_a?(String)
|
24
|
+
Sentry.capture_message(exception_or_message, args)
|
25
|
+
else
|
26
|
+
Sentry.capture_exception(exception_or_message, args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.is_configured?
|
31
|
+
Sentry.get_current_client != nil
|
18
32
|
end
|
19
33
|
|
20
34
|
def self.configure
|
21
|
-
|
22
|
-
|
35
|
+
raise GovukError::AlreadyInitialised if is_configured?
|
36
|
+
|
37
|
+
Sentry.init do |sentry_config|
|
38
|
+
config = Configuration.new(sentry_config)
|
39
|
+
yield config if block_given?
|
40
|
+
end
|
23
41
|
end
|
24
42
|
end
|
@@ -3,20 +3,82 @@ require "govuk_app_config/govuk_error/govuk_data_sync"
|
|
3
3
|
|
4
4
|
module GovukError
|
5
5
|
class Configuration < SimpleDelegator
|
6
|
-
attr_reader :data_sync
|
7
|
-
attr_accessor :
|
6
|
+
attr_reader :data_sync
|
7
|
+
attr_accessor :data_sync_excluded_exceptions
|
8
8
|
|
9
9
|
def initialize(_sentry_configuration)
|
10
10
|
super
|
11
|
-
@sentry_environment = ENV["SENTRY_CURRENT_ENV"]
|
12
11
|
@data_sync = GovukDataSync.new(ENV["GOVUK_DATA_SYNC_PERIOD"])
|
13
|
-
|
14
|
-
|
12
|
+
set_up_defaults
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_up_defaults
|
16
|
+
# These are the environments (described by the `SENTRY_CURRENT_ENV`
|
17
|
+
# ENV variable) where we want to capture Sentry errors. If
|
18
|
+
# `SENTRY_CURRENT_ENV` isn't in this list, or isn't defined, then
|
19
|
+
# don't capture the error.
|
20
|
+
self.enabled_environments = %w[
|
21
|
+
integration-blue-aws
|
22
|
+
staging
|
23
|
+
production
|
24
|
+
]
|
25
|
+
|
26
|
+
self.excluded_exceptions = [
|
27
|
+
# Default ActionDispatch rescue responses
|
28
|
+
"ActionController::RoutingError",
|
29
|
+
"AbstractController::ActionNotFound",
|
30
|
+
"ActionController::MethodNotAllowed",
|
31
|
+
"ActionController::UnknownHttpMethod",
|
32
|
+
"ActionController::NotImplemented",
|
33
|
+
"ActionController::UnknownFormat",
|
34
|
+
"Mime::Type::InvalidMimeType",
|
35
|
+
"ActionController::MissingExactTemplate",
|
36
|
+
"ActionController::InvalidAuthenticityToken",
|
37
|
+
"ActionController::InvalidCrossOriginRequest",
|
38
|
+
"ActionDispatch::Http::Parameters::ParseError",
|
39
|
+
"ActionController::BadRequest",
|
40
|
+
"ActionController::ParameterMissing",
|
41
|
+
"Rack::QueryParser::ParameterTypeError",
|
42
|
+
"Rack::QueryParser::InvalidParameterError",
|
43
|
+
# Default ActiveRecord rescue responses
|
44
|
+
"ActiveRecord::RecordNotFound",
|
45
|
+
"ActiveRecord::StaleObjectError",
|
46
|
+
"ActiveRecord::RecordInvalid",
|
47
|
+
"ActiveRecord::RecordNotSaved",
|
48
|
+
# Additional items
|
49
|
+
"ActiveJob::DeserializationError",
|
50
|
+
"CGI::Session::CookieStore::TamperedWithCookie",
|
51
|
+
"GdsApi::HTTPIntermittentServerError",
|
52
|
+
"GdsApi::TimedOutException",
|
53
|
+
"Mongoid::Errors::DocumentNotFound",
|
54
|
+
"Sinatra::NotFound",
|
55
|
+
"Slimmer::IntermittentRetrievalError",
|
56
|
+
]
|
57
|
+
|
58
|
+
# This will exclude exceptions that are triggered by one of the ignored
|
59
|
+
# exceptions. For example, when any exception occurs in a template,
|
60
|
+
# Rails will raise a ActionView::Template::Error, instead of the original error.
|
61
|
+
self.inspect_exception_causes_for_exclusion = true
|
62
|
+
|
63
|
+
# List of exceptions to ignore if they take place during the data sync.
|
64
|
+
# Some errors are transient in nature, e.g. PostgreSQL databases being
|
65
|
+
# unavailable, and add little value. In fact, their presence can greatly
|
66
|
+
# increase the number of errors being sent and risk genuine errors being
|
67
|
+
# rate-limited by Sentry.
|
68
|
+
self.data_sync_excluded_exceptions = [
|
69
|
+
"PG::Error",
|
70
|
+
"GdsApi::ContentStore::ItemNotFound",
|
71
|
+
]
|
72
|
+
|
15
73
|
@before_send_callbacks = [
|
16
|
-
ignore_exceptions_if_not_in_active_sentry_env,
|
17
74
|
ignore_excluded_exceptions_in_data_sync,
|
18
75
|
increment_govuk_statsd_counters,
|
19
76
|
]
|
77
|
+
# Need to invoke an arbitrary `before_send=` in order to trigger the
|
78
|
+
# `before_send_callbacks` behaviour
|
79
|
+
self.before_send = lambda { |error_or_event, _hint|
|
80
|
+
error_or_event
|
81
|
+
}
|
20
82
|
end
|
21
83
|
|
22
84
|
def before_send=(closure)
|
@@ -26,10 +88,6 @@ module GovukError
|
|
26
88
|
|
27
89
|
protected
|
28
90
|
|
29
|
-
def ignore_exceptions_if_not_in_active_sentry_env
|
30
|
-
->(event, _hint) { event if active_sentry_environments.include?(sentry_environment) }
|
31
|
-
end
|
32
|
-
|
33
91
|
def ignore_excluded_exceptions_in_data_sync
|
34
92
|
lambda { |event, hint|
|
35
93
|
data_sync_ignored_error = data_sync_excluded_exceptions.any? do |exception_to_ignore|
|
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.0.0.pre.
|
4
|
+
version: 4.0.0.pre.4
|
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-06-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstasher
|
@@ -244,7 +244,6 @@ files:
|
|
244
244
|
- lib/govuk_app_config/govuk_content_security_policy.rb
|
245
245
|
- lib/govuk_app_config/govuk_error.rb
|
246
246
|
- lib/govuk_app_config/govuk_error/configuration.rb
|
247
|
-
- lib/govuk_app_config/govuk_error/configure.rb
|
248
247
|
- lib/govuk_app_config/govuk_error/govuk_data_sync.rb
|
249
248
|
- lib/govuk_app_config/govuk_healthcheck.rb
|
250
249
|
- lib/govuk_app_config/govuk_healthcheck/active_record.rb
|
@@ -1,62 +0,0 @@
|
|
1
|
-
GovukError.configure do |config|
|
2
|
-
# These are the environments (described by the `SENTRY_CURRENT_ENV`
|
3
|
-
# ENV variable) where we want to capture Sentry errors. If
|
4
|
-
# `SENTRY_CURRENT_ENV` isn't in this list, or isn't defined, then
|
5
|
-
# don't capture the error.
|
6
|
-
config.active_sentry_environments = %w[
|
7
|
-
integration-blue-aws
|
8
|
-
staging
|
9
|
-
production
|
10
|
-
]
|
11
|
-
|
12
|
-
config.excluded_exceptions = [
|
13
|
-
# Default ActionDispatch rescue responses
|
14
|
-
"ActionController::RoutingError",
|
15
|
-
"AbstractController::ActionNotFound",
|
16
|
-
"ActionController::MethodNotAllowed",
|
17
|
-
"ActionController::UnknownHttpMethod",
|
18
|
-
"ActionController::NotImplemented",
|
19
|
-
"ActionController::UnknownFormat",
|
20
|
-
"Mime::Type::InvalidMimeType",
|
21
|
-
"ActionController::MissingExactTemplate",
|
22
|
-
"ActionController::InvalidAuthenticityToken",
|
23
|
-
"ActionController::InvalidCrossOriginRequest",
|
24
|
-
"ActionDispatch::Http::Parameters::ParseError",
|
25
|
-
"ActionController::BadRequest",
|
26
|
-
"ActionController::ParameterMissing",
|
27
|
-
"Rack::QueryParser::ParameterTypeError",
|
28
|
-
"Rack::QueryParser::InvalidParameterError",
|
29
|
-
# Default ActiveRecord rescue responses
|
30
|
-
"ActiveRecord::RecordNotFound",
|
31
|
-
"ActiveRecord::StaleObjectError",
|
32
|
-
"ActiveRecord::RecordInvalid",
|
33
|
-
"ActiveRecord::RecordNotSaved",
|
34
|
-
# Additional items
|
35
|
-
"ActiveJob::DeserializationError",
|
36
|
-
"CGI::Session::CookieStore::TamperedWithCookie",
|
37
|
-
"GdsApi::HTTPIntermittentServerError",
|
38
|
-
"GdsApi::TimedOutException",
|
39
|
-
"Mongoid::Errors::DocumentNotFound",
|
40
|
-
"Sinatra::NotFound",
|
41
|
-
"Slimmer::IntermittentRetrievalError",
|
42
|
-
]
|
43
|
-
|
44
|
-
# This will exclude exceptions that are triggered by one of the ignored
|
45
|
-
# exceptions. For example, when any exception occurs in a template,
|
46
|
-
# Rails will raise a ActionView::Template::Error, instead of the original error.
|
47
|
-
config.inspect_exception_causes_for_exclusion = true
|
48
|
-
|
49
|
-
# List of exceptions to ignore if they take place during the data sync.
|
50
|
-
# Some errors are transient in nature, e.g. PostgreSQL databases being
|
51
|
-
# unavailable, and add little value. In fact, their presence can greatly
|
52
|
-
# increase the number of errors being sent and risk genuine errors being
|
53
|
-
# rate-limited by Sentry.
|
54
|
-
config.data_sync_excluded_exceptions = [
|
55
|
-
"PG::Error",
|
56
|
-
"GdsApi::ContentStore::ItemNotFound",
|
57
|
-
]
|
58
|
-
|
59
|
-
config.before_send = lambda { |error_or_event, _hint|
|
60
|
-
error_or_event
|
61
|
-
}
|
62
|
-
end
|