govuk_app_config 3.2.0 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b8b7a21f65eaad2497889dc826180443c5aae98bde55db7922cb85a6953b43f
4
- data.tar.gz: 7fc22880f83e1dc5ceca2eab8f53d4842b39fd5c42431d9c53bdf985f08d1c9c
3
+ metadata.gz: 4ef48ff1d4edbc117dba4f4d8b09b862dacdc5faa06f879c9094e695d29025df
4
+ data.tar.gz: e6465d32e6522637f3a7cdd5681c3286bf3f1fd96657099e3e28ce0e716468fa
5
5
  SHA512:
6
- metadata.gz: bf269f9b44cfa14887ac6c465cd76ac8f799a6c5c96e08d3728da3b48bece7093ffba68080fba509590e931bc1efdbcbcaf33e5fb5ab4055047c1e6a9c0fb9c2
7
- data.tar.gz: 134e5c912a8fab095fafc1be65cdaa0b84f2aa45a04bcd1c5aa776df8b4743e25c8c9891b9c6115028a5dc047b48d15a229be62cf57850866b5b6c4e4f6df316
6
+ metadata.gz: dd241443a0a59323c2210c67fb04268bd7a662cff61c7eef3580bcde200efd6d38d7efa2bfb22b7642761fd1f929f2e8a4259fe12af8692338f69ce024a9cd15
7
+ data.tar.gz: 8470470f8cf108e25155b6eca6c64f82a9f79b601c22889399bfe71ce87cc39bb3e80a6efda7d30432121766721143329cc5271c591dc75ec36e495687d06a65
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 2.6.5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 3.3.0
2
+
3
+ - 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))
4
+
1
5
  # 3.2.0
2
6
 
3
7
  - Add Speedcurve's LUX to connect-src policy ([#206](https://github.com/alphagov/govuk_app_config/pull/206))
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
- `before_send` callback doesn't return `nil`.
115
+ `should_capture` callback returns `true`.
116
116
 
117
117
  ```ruby
118
118
  GovukError.configure do |config|
119
- config.before_send = lambda do |error_or_event|
120
- error_or_event == "do capture" ? error_or_event : nil
119
+ config.should_capture = lambda do |error_or_event|
120
+ error_or_event == "do capture"
121
121
  end
122
122
  end
123
123
  ```
@@ -12,26 +12,32 @@ module GovukError
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
- @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
- ]
15
+ self.should_capture = ignore_exceptions_based_on_env_and_data_sync
20
16
  end
21
17
 
22
- def before_send=(closure)
23
- @before_send_callbacks.insert(-2, closure)
24
- super(run_before_send_callbacks)
18
+ def should_capture=(closure)
19
+ combined = lambda do |error_or_event|
20
+ (ignore_exceptions_based_on_env_and_data_sync.call(error_or_event) && closure.call(error_or_event))
21
+ end
22
+
23
+ super(combined)
25
24
  end
26
25
 
27
26
  protected
28
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
+
29
35
  def ignore_exceptions_if_not_in_active_sentry_env
30
- ->(error_or_event, _hint) { error_or_event if active_sentry_environments.include?(sentry_environment) }
36
+ ->(_error_or_event) { active_sentry_environments.include?(sentry_environment) }
31
37
  end
32
38
 
33
39
  def ignore_excluded_exceptions_in_data_sync
34
- lambda { |error_or_event, _hint|
40
+ lambda { |error_or_event|
35
41
  data_sync_ignored_error = data_sync_excluded_exceptions.any? do |exception_to_ignore|
36
42
  exception_to_ignore = Object.const_get(exception_to_ignore) unless exception_to_ignore.is_a?(Module)
37
43
  exception_chain = Raven::Utils::ExceptionCauseChain.exception_to_array(error_or_event)
@@ -42,27 +48,8 @@ module GovukError
42
48
  false
43
49
  end
44
50
 
45
- error_or_event unless data_sync.in_progress? && data_sync_ignored_error
46
- }
47
- end
48
-
49
- def increment_govuk_statsd_counters
50
- lambda { |error_or_event, _hint|
51
- GovukStatsd.increment("errors_occurred")
52
- GovukStatsd.increment("error_types.#{error_or_event.class.name.demodulize.underscore}")
53
- error_or_event
51
+ !(data_sync.in_progress? && data_sync_ignored_error)
54
52
  }
55
53
  end
56
-
57
- def run_before_send_callbacks
58
- lambda do |error_or_event, hint|
59
- result = error_or_event
60
- @before_send_callbacks.each do |callback|
61
- result = callback.call(error_or_event, hint)
62
- break if result.nil?
63
- end
64
- result
65
- end
66
- end
67
54
  end
68
55
  end
@@ -1,4 +1,10 @@
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
+
2
8
  config.silence_ready = !Rails.env.production? if defined?(Rails)
3
9
 
4
10
  # These are the environments (described by the `SENTRY_CURRENT_ENV`
@@ -58,10 +64,6 @@ GovukError.configure do |config|
58
64
  "GdsApi::ContentStore::ItemNotFound",
59
65
  ]
60
66
 
61
- config.before_send = lambda { |error_or_event, _hint|
62
- error_or_event
63
- }
64
-
65
67
  config.transport_failure_callback = proc {
66
68
  GovukStatsd.increment("error_reports_failed")
67
69
  }
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "3.2.0".freeze
2
+ VERSION = "3.3.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: 3.2.0
4
+ version: 3.3.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-16 00:00:00.000000000 Z
11
+ date: 2021-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  - !ruby/object:Gem::Version
266
266
  version: '0'
267
267
  requirements: []
268
- rubygems_version: 3.1.4
268
+ rubygems_version: 3.0.3
269
269
  signing_key:
270
270
  specification_version: 4
271
271
  summary: Base configuration for GOV.UK applications