From 25395c7a1c367e96667eb8e5bbe0cc86bfbc701f Mon Sep 17 00:00:00 2001 From: Benjamin Eskola Date: Thu, 3 Dec 2020 15:49:18 +0000 Subject: [PATCH] Add govuk_app_config version to every sentry call This is to simplify debugging problems with error handling, see: https://trello.com/c/guK81BGF/2239-3-send-govukappconfig-version-with-errors --- lib/govuk_app_config/govuk_error.rb | 4 ++++ lib/govuk_app_config/version.rb | 2 +- spec/lib/govuk_error_spec.rb | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/govuk_app_config/govuk_error.rb b/lib/govuk_app_config/govuk_error.rb index 8074cba2..c1253c70 100644 --- a/lib/govuk_app_config/govuk_error.rb +++ b/lib/govuk_app_config/govuk_error.rb @@ -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 = {}) @@ -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 diff --git a/lib/govuk_app_config/version.rb b/lib/govuk_app_config/version.rb index 12bc39ed..0d1b5467 100644 --- a/lib/govuk_app_config/version.rb +++ b/lib/govuk_app_config/version.rb @@ -1,3 +1,3 @@ module GovukAppConfig - VERSION = "2.7.1".freeze + VERSION = "2.8.0".freeze end diff --git a/spec/lib/govuk_error_spec.rb b/spec/lib/govuk_error_spec.rb index 98373b3f..981bba1e 100644 --- a/spec/lib/govuk_error_spec.rb +++ b/spec/lib/govuk_error_spec.rb @@ -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