govuk_app_config 3.0.0 → 3.1.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: 68431d222e7798dd3027131ef5d05ea7cfab1f7df54d5e06274f2de19f4e51ea
4
- data.tar.gz: 6c5273bd18e606f6269279d547e91630574d61dc7a1151bfbbecd55f3f38d371
3
+ metadata.gz: e875cdeb8303839a0f8cf66370ff3d355b7c770877dad6216fc47989ebc5c7a6
4
+ data.tar.gz: b060cceb5e5d54c1e81b76a01585ff75eeae4d630a3f9102fea91597eaf00a95
5
5
  SHA512:
6
- metadata.gz: '06387b0c49fe60c29728fdda8a8f3bfe529c9b8db2b87ef795b20dfb2ef157667102768d496a7cb1ccad4425265051075f9886d9e155632bb68c47626480c882'
7
- data.tar.gz: 4ec51524d66f98be80b779d28ec65d0355b721e2fd794c03f4c61a573371c800e46f6d7c6ee514dd080430763803f7396bcd37c0e4bd7e57d33d886f6ae59980
6
+ metadata.gz: b7d7d5b3f26029738e974dd096f2ce8ade8f44be23f87526cc589da2219d2847b58553ddd57d320d5f412b65c5349bde8b2a8f746efb02286e4867fe594a2214
7
+ data.tar.gz: abfe7e93cc5b2e1b30cbcca6886a71f3f42f1e41d05cb12268a4ca8b9ae56b74d4f68dcafd602ab9166f5df8c7466c83c5dffa4332270f08172c7e73972220e2
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "03:00"
8
+ open-pull-requests-limit: 10
9
+ ignore:
10
+ - dependency-name: aws-xray-sdk
11
+ versions:
12
+ - "> 0.10.0"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 3.1.0
2
+
3
+ - Remove support for `should_capture` callbacks in favour of `before_send` ([#196](https://github.com/alphagov/govuk_app_config/pull/196))
4
+
1
5
  # 3.0.0
2
6
 
3
7
  * BREAKING: Implement RFC 141 - remove unsuitable healthchecks and return a 500 on healthcheck failure ([#193](https://github.com/alphagov/govuk_app_config/pull/193))
@@ -12,32 +12,26 @@ 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
- self.should_capture = ignore_exceptions_based_on_env_and_data_sync
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
+ ]
20
+ super.before_send = run_before_send_callbacks
16
21
  end
17
22
 
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)
23
+ def before_send=(closure)
24
+ @before_send_callbacks.insert(-2, closure)
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
- ->(_error_or_event) { active_sentry_environments.include?(sentry_environment) }
30
+ ->(error_or_event, _hint) { error_or_event if active_sentry_environments.include?(sentry_environment) }
37
31
  end
38
32
 
39
33
  def ignore_excluded_exceptions_in_data_sync
40
- lambda { |error_or_event|
34
+ lambda { |error_or_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
37
  exception_chain = Raven::Utils::ExceptionCauseChain.exception_to_array(error_or_event)
@@ -45,11 +39,30 @@ module GovukError
45
39
  rescue NameError
46
40
  # the exception type represented by the exception_to_ignore string
47
41
  # doesn't even exist in this environment, so won't be found in the chain
48
- false
42
+ nil
49
43
  end
50
44
 
51
- !(data_sync.in_progress? && data_sync_ignored_error)
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
52
54
  }
53
55
  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
54
67
  end
55
68
  end
@@ -1,10 +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
2
  config.silence_ready = !Rails.env.production? if defined?(Rails)
9
3
 
10
4
  # These are the environments (described by the `SENTRY_CURRENT_ENV`
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "3.0.0".freeze
2
+ VERSION = "3.1.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.0.0
4
+ version: 3.1.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-04-26 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher
@@ -211,6 +211,7 @@ executables: []
211
211
  extensions: []
212
212
  extra_rdoc_files: []
213
213
  files:
214
+ - ".github/dependabot.yml"
214
215
  - ".gitignore"
215
216
  - ".rspec"
216
217
  - ".rubocop.yml"