Skip to content

Commit

Permalink
Add slack channel when logging error.
Browse files Browse the repository at this point in the history
Signed-off-by: Melchior MOULIN <m.moulin@criteo.com>
  • Loading branch information
Melchior MOULIN committed Feb 4, 2020
1 parent 0f2c65d commit a4335d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion notify/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -183,5 +184,9 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
// Only 5xx response codes are recoverable and 2xx codes are successful.
// https://api.slack.com/incoming-webhooks#handling_errors
// https://api.slack.com/changelog/2016-05-17-changes-to-errors-for-incoming-webhooks
return n.retrier.Check(resp.StatusCode, resp.Body)
retry, err := n.retrier.Check(resp.StatusCode, resp.Body)
if err != nil {
err = fmt.Errorf("%v on slack channel: %s", err, req.Channel)
}
return retry, err
}

0 comments on commit a4335d5

Please sign in to comment.