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 a945fed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion notify/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"net/http"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -183,5 +185,7 @@ 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)
err = errors.Wrap(err, fmt.Sprintf("channel %q", req.Channel))
return retry, err
}

0 comments on commit a945fed

Please sign in to comment.