Move sentry alerting into function for easier calling from other services.