-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade logstasher gem to add error notification
We log the postcode_errors with `logstasher` to JSON-style logs so that the errors can be viewed in Kibana. `logstasher` supports subscribing to ActiveSupport::Notifications, which we use to log the postcode errors. https://github.com/shadabahmed/logstasher#listening-to-activesupportnotifications-events We upgrade `logstasher` to release `0.6.2`. Initially we attempted to upgrade to the latest release `0.8.6`, but custom fields were not being output in the logs, notification subscription did not work, log messages for rendering view templates were being included and the JSON structure of the output was different (`fields` being deprecated since `0.6.5`). This appears not to be a straight-forward API change but rather changes in the internal architecture. In the interest of time I have settled on `0.6.2` as that includes the `watch` method and does not alter the previous logging output. I have logged an issue against the `logstasher` repo -> shadabahmed/logstasher#92 to ask about the breaking change to notification subscriptions. The commit adds the following to the JSON output: `"postcode_error_notification":{ "postcode_error":"invalidPostcodeFormat" },`
- Loading branch information
1 parent
7af9f6c
commit 69e48c7
Showing
7 changed files
with
78 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class LocationErrorTest < ActiveSupport::TestCase | ||
context '#initialize' do | ||
should 'default to default message when no message given' do | ||
error = LocationError.new(postcode_error = 'some_error', message = nil) | ||
assert_equal(error.message, 'formats.local_transaction.invalid_postcode') | ||
end | ||
|
||
context 'when given a postcode_error' do | ||
should 'send the postcode error as a notification' do | ||
ActiveSupport::Notifications.expects(:instrument).with('postcode_error_notification', postcode_error: "some_error") | ||
|
||
error = LocationError.new(postcode_error = 'some_error') | ||
end | ||
end | ||
|
||
context 'when not given a postcode_error' do | ||
should 'not send a postcode_error notification' do | ||
ActiveSupport::Notifications.expects(:instrument).never | ||
|
||
error = LocationError.new | ||
end | ||
end | ||
end | ||
end |