govuk_app_config 4.0.0.pre.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b08ba5468f1f0639c3dab2c7067d7a3acff2169ce85a246ceb2a976b04686a7
4
- data.tar.gz: ce9d8876d37175726d4aa81633e4b11232975dd3d65d24bca6ac58b219248b09
3
+ metadata.gz: f8077ef6fb7147f51cfa723573145d8552deccc046e51fb7fa5870517b44c404
4
+ data.tar.gz: f172b22ff57d9a7c86a2a6cd9d25b5f27a5f207e714e82f40e031d3ba979aadf
5
5
  SHA512:
6
- metadata.gz: a0eb71467c7fa26805e5606bec9f96312c6bb5e0f0d0ef3b93e1a8cfa5d556164f5ac537c9606416724eb93acbef298f57163a16876ddb5ba48b5dea05c94227
7
- data.tar.gz: cae07877f651a180c2c62a7fd32a15714421e2dfee5c7fda5957d7601d5cd99c57e110c3b2071d7d5a4dac62c924e662c1dc70379f206b5de849ac373999d3e4
6
+ metadata.gz: 59bf46da65446015dd8521f505f01af02f04149490f8d653e6e3436fe9512a920637211054a3e6cfc75cc66f15e81036631a9921410b2226f3d5489cf6e65182
7
+ data.tar.gz: f70c89f913ead21b565f92a6150958b88469da6585166077c3e112cd60444377e5593d56f8d9881379e24e859406741668aad545a046c4d48744f6bbc08d6820
data/CHANGELOG.md CHANGED
@@ -1,9 +1,41 @@
1
- # 4.0.0.pre-1
1
+ # 4.0.0
2
+
3
+ - BREAKING: replaces deprecated `sentry-raven` with `sentry-ruby` and `sentry-rails`. Follow the **[migration guide](https://docs.sentry.io/platforms/ruby/migration/)** before upgrading to this version of govuk_app_config to ensure full compatibility with the new gems.
4
+ - BREAKING: `GovukError.configure` can only be called once, and non-Rails apps will have to manually call `GovukError.configure` in order to initialise Sentry.
5
+ - BREAKING: apps will no longer increment the `error_reports_failed` statsd if events fail to get sent to Sentry.
6
+ - BREAKING: the behaviour of `before_send` has changed, and the `should_capture` method is deprecated.
7
+ - See pre-release notes below for details.
8
+ - PR: [#212](https://github.com/alphagov/govuk_app_config/pull/212)
9
+
10
+ # 4.0.0.pre.4
11
+
12
+ - Fix Sentry client initialisation ([#205](https://github.com/alphagov/govuk_app_config/pull/205)).
13
+ - BREAKING: non-Rails apps will need to manually call `GovukError.configure` in order to initialise Sentry.
14
+ - BREAKING: `GovukError.configure` can only be called once by the downstream application.
15
+
16
+ # 4.0.0.pre.3
17
+
18
+ - 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)).
19
+
20
+ # 4.0.0.pre.2
21
+
22
+ - Fix default Sentry configuration ([#202](https://github.com/alphagov/govuk_app_config/pull/202)).
23
+ - BREAKING: this means no more `silence_ready` or `transport_failure_callback` options.
24
+
25
+ # 4.0.0.pre.1
2
26
 
3
27
  - 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.
4
- - This release also fixes the `data_sync_excluded_exceptions` behaviour that has been broken since v3.1.0.
28
+ - This release also fixes the `data_sync_excluded_exceptions` behaviour that was broken in v3.1.0 (later fixed in v3.3.0, which was released after 4.0.0.pre.1).
5
29
  - Released as a pre-release to identify and fix any problems before a wider rollout.
6
30
 
31
+ # 3.3.0
32
+
33
+ - Revert the `should_capture`/`before_send` consolidation introduced in 3.1.0. This fixes the `data_sync_excluded_exceptions` behaviour that has been broken since v3.1.0. ([#211](https://github.com/alphagov/govuk_app_config/pull/211))
34
+
35
+ # 3.2.0
36
+
37
+ - Add Speedcurve's LUX to connect-src policy ([#206](https://github.com/alphagov/govuk_app_config/pull/206))
38
+
7
39
  # 3.1.1
8
40
 
9
41
  - Fix the new before_send behaviour & tests, and add documentation ([#197](https://github.com/alphagov/govuk_app_config/pull/197))
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.active_sentry_environments << "my-test-environment"
90
+ config.enabled_environments << "my-test-environment"
91
91
  end
92
92
  ```
93
93
 
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
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-rails", "~> 4.5.0"
24
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"
@@ -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
@@ -78,7 +78,13 @@ module GovukContentSecurityPolicy
78
78
  # Allow JSON call to klick2contact - HMPO web chat provider
79
79
  "gov.klick2contact.com",
80
80
  # Allow connecting to Verify to check whether the user is logged in
81
- "www.signin.service.gov.uk"
81
+ "www.signin.service.gov.uk",
82
+ # Allow connection to Speedcurve's CDN for LUX - used for
83
+ # real user metrics on GOV.UK. This loads using an image
84
+ # (see image policy), but returns a JavaScript file -
85
+ # which is why this has to be added to the `connect-src`
86
+ # policy as well.
87
+ "lux.speedcurve.com"
82
88
 
83
89
  # Disallow all <object>, <embed>, and <applet> elements
84
90
  #
@@ -1,9 +1,16 @@
1
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"
5
6
 
6
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
+
7
14
  def self.notify(exception_or_message, args = {})
8
15
  # Allow users to use `parameters` as a key like the Airbrake
9
16
  # client, allowing easy upgrades.
@@ -13,11 +20,23 @@ module GovukError
13
20
  args[:tags] ||= {}
14
21
  args[:tags][:govuk_app_config_version] = GovukAppConfig::VERSION
15
22
 
16
- Sentry.capture_exception(exception_or_message, args)
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
17
32
  end
18
33
 
19
34
  def self.configure
20
- @configuration ||= Configuration.new(Sentry::Configuration.new)
21
- yield @configuration
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
22
41
  end
23
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, :sentry_environment
7
- attr_accessor :active_sentry_environments, :data_sync_excluded_exceptions
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
- self.active_sentry_environments = []
14
- self.data_sync_excluded_exceptions = []
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|
@@ -3,5 +3,9 @@ module GovukAppConfig
3
3
  config.before_initialize do
4
4
  GovukLogging.configure if Rails.env.production?
5
5
  end
6
+
7
+ config.after_initialize do
8
+ GovukError.configure unless GovukError.is_configured?
9
+ end
6
10
  end
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "4.0.0.pre.1".freeze
2
+ VERSION = "4.0.0".freeze
3
3
  end
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.1
4
+ version: 4.0.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: 2021-06-04 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.2.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: sentry-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 4.5.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 4.5.0
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: sentry-ruby
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -230,7 +244,6 @@ files:
230
244
  - lib/govuk_app_config/govuk_content_security_policy.rb
231
245
  - lib/govuk_app_config/govuk_error.rb
232
246
  - lib/govuk_app_config/govuk_error/configuration.rb
233
- - lib/govuk_app_config/govuk_error/configure.rb
234
247
  - lib/govuk_app_config/govuk_error/govuk_data_sync.rb
235
248
  - lib/govuk_app_config/govuk_healthcheck.rb
236
249
  - lib/govuk_app_config/govuk_healthcheck/active_record.rb
@@ -261,9 +274,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
274
  version: '2.6'
262
275
  required_rubygems_version: !ruby/object:Gem::Requirement
263
276
  requirements:
264
- - - ">"
277
+ - - ">="
265
278
  - !ruby/object:Gem::Version
266
- version: 1.3.1
279
+ version: '0'
267
280
  requirements: []
268
281
  rubygems_version: 3.0.3
269
282
  signing_key:
@@ -1,68 +0,0 @@
1
- GovukError.configure do |config|
2
- config.silence_ready = !Rails.env.production? if defined?(Rails)
3
-
4
- # These are the environments (described by the `SENTRY_CURRENT_ENV`
5
- # ENV variable) where we want to capture Sentry errors. If
6
- # `SENTRY_CURRENT_ENV` isn't in this list, or isn't defined, then
7
- # don't capture the error.
8
- config.active_sentry_environments = %w[
9
- integration-blue-aws
10
- staging
11
- production
12
- ]
13
-
14
- config.excluded_exceptions = [
15
- # Default ActionDispatch rescue responses
16
- "ActionController::RoutingError",
17
- "AbstractController::ActionNotFound",
18
- "ActionController::MethodNotAllowed",
19
- "ActionController::UnknownHttpMethod",
20
- "ActionController::NotImplemented",
21
- "ActionController::UnknownFormat",
22
- "Mime::Type::InvalidMimeType",
23
- "ActionController::MissingExactTemplate",
24
- "ActionController::InvalidAuthenticityToken",
25
- "ActionController::InvalidCrossOriginRequest",
26
- "ActionDispatch::Http::Parameters::ParseError",
27
- "ActionController::BadRequest",
28
- "ActionController::ParameterMissing",
29
- "Rack::QueryParser::ParameterTypeError",
30
- "Rack::QueryParser::InvalidParameterError",
31
- # Default ActiveRecord rescue responses
32
- "ActiveRecord::RecordNotFound",
33
- "ActiveRecord::StaleObjectError",
34
- "ActiveRecord::RecordInvalid",
35
- "ActiveRecord::RecordNotSaved",
36
- # Additional items
37
- "ActiveJob::DeserializationError",
38
- "CGI::Session::CookieStore::TamperedWithCookie",
39
- "GdsApi::HTTPIntermittentServerError",
40
- "GdsApi::TimedOutException",
41
- "Mongoid::Errors::DocumentNotFound",
42
- "Sinatra::NotFound",
43
- "Slimmer::IntermittentRetrievalError",
44
- ]
45
-
46
- # This will exclude exceptions that are triggered by one of the ignored
47
- # exceptions. For example, when any exception occurs in a template,
48
- # Rails will raise a ActionView::Template::Error, instead of the original error.
49
- config.inspect_exception_causes_for_exclusion = true
50
-
51
- # List of exceptions to ignore if they take place during the data sync.
52
- # Some errors are transient in nature, e.g. PostgreSQL databases being
53
- # unavailable, and add little value. In fact, their presence can greatly
54
- # increase the number of errors being sent and risk genuine errors being
55
- # rate-limited by Sentry.
56
- config.data_sync_excluded_exceptions = [
57
- "PG::Error",
58
- "GdsApi::ContentStore::ItemNotFound",
59
- ]
60
-
61
- config.before_send = lambda { |error_or_event, _hint|
62
- error_or_event
63
- }
64
-
65
- config.transport_failure_callback = proc {
66
- GovukStatsd.increment("error_reports_failed")
67
- }
68
- end