-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
notify/opsgenie: log error from OpsGenie API #1965
notify/opsgenie: log error from OpsGenie API #1965
Conversation
Signed-off-by: Simon Pasquier <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I think it makes sense, but I would suggest splitting this retry function (and maybe rename to isRetriable
) to keep things clear. What to do you think?
Otherwise LGTM
} | ||
|
||
return false, nil | ||
err := errors.Errorf("unexpected status code %v", statusCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we put too many things into this function to just name it retry
(:
Can we have isRetriable
with what we have previously and then have this:
err := errors.Errorf("unexpected status code %v", statusCode)
if body != nil {
if bs, errRead := ioutil.ReadAll(body); errRead == nil {
err = errors.Errorf("%s: %s", err, string(bs))
}
}
in Notify
if the isRetriable(..)
is false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it wouldn't work as-is because we can have errors that shouldn't be retried and for which logging the response body is still useful IMO.
FWIW the current form is consistent with what we have in other places (eg Slack). If anything we should factor out what is common across notifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me. maybe it would be good to look at the notifiers now that they're all nicely split out and see what we can simplify, but definitely for another issue/pr.
I'll have a look for the next step. |
Signed-off-by: Simon Pasquier <[email protected]>
Ref: https://groups.google.com/d/msg/prometheus-users/3sAQ9kxEgPI/rE-ADUYiBAAJ
Tested against OpsGenie API, the error message looks like this: