I’ve created an OTP application using Supervised GenStage producer/consumer model and would like to add in the ability to get notified (via email and/or pagerduty) if any supervised processes fail.
I don’t have any exception handling code, so all exceptions and errors that I haven’t specifically handled using the {:ok, term}, {:error, term} mechanims should bubble to the top and cause a crash, which the supervisor would notice a restart the application.
I would like to know when this happens via some notification.
I originally thought about adding something in the supervisor, but I read that is frowned upon. Supervisors should be as minimal as possible.
I also read the GenStage/GenServer terminate callback doesn’t always get executed during a crash so that also is not an option.
What’s the best/canonical way to handle this?