govuk_app_config 2.5.2 → 2.6.0
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 +4 -0
- data/README.md +13 -1
- data/lib/govuk_app_config/govuk_error/configuration.rb +17 -4
- data/lib/govuk_app_config/govuk_error/configure.rb +10 -0
- data/lib/govuk_app_config/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42c7ced77e0c6592acdcbd98f489a2ed0ac60e7651aad238f4a4cdaa5f840952
|
4
|
+
data.tar.gz: 577864e98f093d456e3c3f911a8b67bd09dd7f25d9484da63fad8fb1473d19a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b19a36fda15dd6a28ca60ab34bfd2b7f1c5ff0c078912f79b8a7936afe69723f5ce8812b3dc1d61afd3eb194eb6de56ecc8e2ac1de5ed7d0d81a507eb457393
|
7
|
+
data.tar.gz: 0ada829997c9a0f659b08dd5095c57420d37d1f0c47e6ddfc82ecbf4ab28e32ccd5a512d9907512020431b5ad6a80374bf9be622d4455ffa5f4e603888869d3e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 2.6.0
|
2
|
+
|
3
|
+
* Ignore errors that occur in temporary environments (adds `active_sentry_environments` config) (https://github.com/alphagov/govuk_app_config/pull/168)
|
4
|
+
|
1
5
|
# 2.5.2
|
2
6
|
|
3
7
|
* Fix govuk_app_config in Ruby 2.7 environments by explicitly requiring the 'delegate' library (https://github.com/alphagov/govuk_app_config/pull/167)
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ If you include `govuk_app_config` in your `Gemfile`, Rails' autoloading mechanis
|
|
51
51
|
Your app will have to have the following environment variables set:
|
52
52
|
|
53
53
|
- `SENTRY_DSN` - the [Data Source Name (DSN)][dsn] for Sentry
|
54
|
-
- `SENTRY_CURRENT_ENV` - production
|
54
|
+
- `SENTRY_CURRENT_ENV` - e.g. "production". Make sure it is [configured to be active](#active-sentry-environments).
|
55
55
|
- `GOVUK_STATSD_PREFIX` - a Statsd prefix like `govuk.apps.application-name.hostname`
|
56
56
|
|
57
57
|
[dsn]: https://docs.sentry.io/quickstart/#about-the-dsn
|
@@ -79,6 +79,18 @@ GovukError.notify(
|
|
79
79
|
)
|
80
80
|
```
|
81
81
|
|
82
|
+
### Active Sentry environments
|
83
|
+
|
84
|
+
GovukError will only send errors to Sentry if your `SENTRY_CURRENT_ENV` matches one of the 'active environments' in the [default configuration](https://github.com/alphagov/govuk_app_config/blob/master/lib/govuk_app_config/govuk_error/configure.rb). This is to prevent temporary test environments from flooding our Sentry account with errors.
|
85
|
+
|
86
|
+
You can add your environment to the list of active Sentry environments like so:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
GovukError.configure do |config|
|
90
|
+
config.active_sentry_environments << "my-test-environment"
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
82
94
|
### Error configuration
|
83
95
|
|
84
96
|
You can exclude certain errors from being reported using this:
|
@@ -3,19 +3,21 @@ 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 :data_sync_excluded_exceptions
|
6
|
+
attr_reader :data_sync, :sentry_environment
|
7
|
+
attr_accessor :active_sentry_environments, :data_sync_excluded_exceptions
|
8
8
|
|
9
9
|
def initialize(_raven_configuration)
|
10
10
|
super
|
11
|
+
@sentry_environment = ENV["SENTRY_CURRENT_ENV"]
|
11
12
|
@data_sync = GovukDataSync.new(ENV["GOVUK_DATA_SYNC_PERIOD"])
|
13
|
+
self.active_sentry_environments = []
|
12
14
|
self.data_sync_excluded_exceptions = []
|
13
|
-
self.should_capture =
|
15
|
+
self.should_capture = ignore_exceptions_based_on_env_and_data_sync
|
14
16
|
end
|
15
17
|
|
16
18
|
def should_capture=(closure)
|
17
19
|
combined = lambda do |error_or_event|
|
18
|
-
(
|
20
|
+
(ignore_exceptions_based_on_env_and_data_sync.call(error_or_event) && closure.call(error_or_event))
|
19
21
|
end
|
20
22
|
|
21
23
|
super(combined)
|
@@ -23,6 +25,17 @@ module GovukError
|
|
23
25
|
|
24
26
|
protected
|
25
27
|
|
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
|
+
def ignore_exceptions_if_not_in_active_sentry_env
|
36
|
+
->(_error_or_event) { active_sentry_environments.include?(sentry_environment) }
|
37
|
+
end
|
38
|
+
|
26
39
|
def ignore_excluded_exceptions_in_data_sync
|
27
40
|
lambda { |error_or_event|
|
28
41
|
data_sync_ignored_error = data_sync_excluded_exceptions.any? do |exception_to_ignore|
|
@@ -7,6 +7,16 @@ GovukError.configure do |config|
|
|
7
7
|
|
8
8
|
config.silence_ready = !Rails.env.production? if defined?(Rails)
|
9
9
|
|
10
|
+
# These are the environments (described by the `SENTRY_CURRENT_ENV`
|
11
|
+
# ENV variable) where we want to capture Sentry errors. If
|
12
|
+
# `SENTRY_CURRENT_ENV` isn't in this list, or isn't defined, then
|
13
|
+
# don't capture the error.
|
14
|
+
config.active_sentry_environments = %w[
|
15
|
+
integration-blue-aws
|
16
|
+
staging
|
17
|
+
production
|
18
|
+
]
|
19
|
+
|
10
20
|
config.excluded_exceptions = [
|
11
21
|
# Default ActionDispatch rescue responses
|
12
22
|
"ActionController::RoutingError",
|
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: 2.
|
4
|
+
version: 2.6.0
|
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: 2020-10-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstasher
|