Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Exception notifier #416

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Exception notifier #416

wants to merge 10 commits into from

Conversation

nawilliams
Copy link
Contributor

@nawilliams nawilliams commented Feb 8, 2019

Adds exception notifier gem and removes old 500 page rescue handling.

fixes #412

@nawilliams nawilliams requested a review from Anbranin February 8, 2019 21:33
@@ -10,7 +10,7 @@ def error_email(email, path, user, serializable_error)

@host = Rails.env.production? ? 'hub.parking.umass.edu' : 'localhost:3000'

subject = "Probable-Engine Error Occured #{Time.zone.now}"
subject = "Golf-Cart-Rentals Error Occured #{Time.zone.now}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't have to write our own error mailer anymore with exception notifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through and removed our custom error mailer everywhere, replaced it in one function (related to API errors) with a manual call to exception notifier. Ended up removing some tests, but I wasn't sure if I should replace them or we assume exception notifier works as advertised (and should already be tested internally). Also wasn't sure how to go about testing exception notifier sending email. Let me know if I missed anything or need to add anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it in all our apps so I think at least right now it's safe to assume it works as advertised, and you're right--the gem maintainers should be testing it.
You don't have to test that it sends emails IMO, I at least never have... just make sure the smtp settings are correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, question about this. Tom setup exception_notifier with this config a looong time ago:

  config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "[ERROR] ",
    :sender_address => %{"notifier" <[email protected]>},
    :exception_recipients => %w{[email protected]}
  },
  :slack => {
    :webhook_url => "https://hooks.slack.com/services/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",
    :channel => "#probably-exceptions",
    :additional_parameters => {
      :icon_url => "http://image.jpg",
      :mrkdwn => true
    }
  }

Compared to this which is duplicated from umaps with the names switched out:

GolfCartRentals::Application.config.middleware.use ExceptionNotification::Rack,
email: {
  email_prefix: "Golf-Cart-Rentals Exception: ",
  sender_address: %{"Golf-Cart-Rentals" <[email protected]>},
  exception_recipients: %w{[email protected]}

}

smpte settings are the same, but we have these settings enabled on action mailer in golf cart app:

 config.action_mailer.delivery_method = :smtp
 config.action_mailer.perform_deliveries = true
 config.action_mailer.raise_delivery_errors = true

The first two are defaults, but I'm not sure about raise_delivery_errors as I don't know anything about the mail server configuration.

Do we care about the slack hooks? Does sender address matter for anything other than display?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sender address should be parkserv and I can't back that up.. not like we can reply to it.

Do we care about slack hooks? I don't know if that even works, but if it does, I would feel pretty neutral about it. I do NOT care for getting exception notifications from Slack. Especially since I check my email regularly and that's how all the other exception notifications come in. I just don't see the need. But whatever.

Copy link
Member

@Anbranin Anbranin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I approve but we should use exception notifier to its full capacity and remove anywhere we email our own error emails.

@Anbranin
Copy link
Member

Why those travis errors??

@nawilliams
Copy link
Contributor Author

Why those travis errors??

Not really sure, I'm gonna add in the rails 5.2 update branch once you merge into master and I'll look into it if that doesn't fix the problem.

# Inventory api url
config.inventory_api_uri = 'https://rentalapi.parking.umass.edu/v1/' # not sure what this is yet
end

GolfCartRentals::Application.config.middleware.user ExceptionNotification::Rack,
GolfCartRentals::Application.config.middleware.use ExceptionNotification::Rack,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just use the config declared above, as in all our other apps. No need to re-declare the GolfCartRentals::Application here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace 500 rescuing with ExceptionNotifier gem
2 participants