Skip to content

Commit

Permalink
Add govuk_app_config version to every sentry call
Browse files Browse the repository at this point in the history
This is to simplify debugging problems with error handling, see:
https://trello.com/c/guK81BGF/2239-3-send-govukappconfig-version-with-errors
  • Loading branch information
benjamineskola committed Dec 3, 2020
1 parent c8caa1c commit 25395c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/govuk_app_config/govuk_error.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "sentry-raven"
require "govuk_app_config/govuk_statsd"
require "govuk_app_config/govuk_error/configuration"
require "govuk_app_config/version"

module GovukError
def self.notify(exception_or_message, args = {})
Expand All @@ -9,6 +10,9 @@ def self.notify(exception_or_message, args = {})
args[:extra] ||= {}
args[:extra].merge!(parameters: args.delete(:parameters))

args[:tags] ||= {}
args[:tags][:govuk_app_config_version] = GovukAppConfig::VERSION

Raven.capture_exception(exception_or_message, args)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_app_config/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GovukAppConfig
VERSION = "2.7.1".freeze
VERSION = "2.8.0".freeze
end
10 changes: 9 additions & 1 deletion spec/lib/govuk_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@

GovukError.notify(StandardError.new, parameters: "Something")

expect(Raven).to have_received(:capture_exception).with(StandardError.new, extra: { parameters: "Something" })
expect(Raven).to have_received(:capture_exception).with(StandardError.new, hash_including(extra: { parameters: "Something" }))
end

it "sends the version along with the request" do
allow(Raven).to receive(:capture_exception)

GovukError.notify(StandardError.new, parameters: "Something")

expect(Raven).to have_received(:capture_exception).with(StandardError.new, hash_including(tags: { govuk_app_config_version: /^[0-9.]+$/ }))
end
end

Expand Down

0 comments on commit 25395c7

Please sign in to comment.