[core] Reduce variance of Sentry errors containing IPs

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-05-27 16:46:33 +02:00
parent a136902d58
commit dc5b5be393
Signed by: luzifer
GPG Key ID: D91C3E91E4CAD6F5

11
main.go
View File

@ -266,7 +266,7 @@ func main() {
} }
if ircHdl, err = newIRCHandler(); err != nil { if ircHdl, err = newIRCHandler(); err != nil {
log.WithError(err).Error("Unable to connect to IRC") log.WithError(err).Error("connecting to IRC")
go func() { go func() {
time.Sleep(ircRetryBackoff) time.Sleep(ircRetryBackoff)
ircRetryBackoff = time.Duration(math.Min(float64(maxIRCRetryBackoff), float64(ircRetryBackoff)*ircRetryBackoffMultiplier)) ircRetryBackoff = time.Duration(math.Min(float64(maxIRCRetryBackoff), float64(ircRetryBackoff)*ircRetryBackoffMultiplier))
@ -278,8 +278,15 @@ func main() {
ircRetryBackoff = initialIRCRetryBackoff // Successfully created, reset backoff ircRetryBackoff = initialIRCRetryBackoff // Successfully created, reset backoff
go func() { go func() {
log.Info("(re-)connecting IRC client")
if err := ircHdl.Run(); err != nil { if err := ircHdl.Run(); err != nil {
log.WithError(err).Error("IRC run exited unexpectedly") log.WithError(err).Debug("IRC connection failed")
// We don't want to spam Sentry with errors each being unique
// and not groupable as it contains `localip:localport -> remoteip:remoteport`
// therefore we replace it with a generic error and just put
// the underlying error in the debug-level log which doesn't
// get sent to Sentry
log.WithError(errors.New("connection to Twitch IRC servers broke")).Error("IRC run exited unexpectedly")
} }
time.Sleep(ircReconnectDelay) time.Sleep(ircReconnectDelay)
ircDisconnected <- struct{}{} ircDisconnected <- struct{}{}