@@ -51,8 +51,8 @@ type Peer interface {
51
51
// to a notification pipeline.
52
52
const MinTimeout = 10 * time .Second
53
53
54
- // defaultStatusCode is the default status code for numTotalFailedNotifications metric
55
- const defaultStatusCode = "5xx"
54
+ // defaultStatusCodeCategory is the default status code category for numTotalFailedNotifications metric
55
+ const defaultStatusCodeCategory = "5xx"
56
56
57
57
// Notifier notifies about alerts under constraints of the given context. It
58
58
// returns an error if unsuccessful and a flag whether the error is
@@ -665,13 +665,17 @@ func NewRetryStage(i Integration, groupName string, metrics *Metrics) *RetryStag
665
665
func (r RetryStage ) Exec (ctx context.Context , l log.Logger , alerts ... * types.Alert ) (context.Context , []* types.Alert , error ) {
666
666
r .metrics .numNotifications .WithLabelValues (r .integration .Name ()).Inc ()
667
667
ctx , alerts , err := r .exec (ctx , l , alerts ... )
668
+
669
+ statusCodeCategory := defaultStatusCodeCategory
668
670
if err != nil {
669
671
if e , ok := errors .Cause (err ).(* ErrorWithStatusCode ); ok {
670
- r .metrics .numTotalFailedNotifications .WithLabelValues (r .integration .Name (), getFailureStatusCodeCategory (e .StatusCode )).Inc ()
671
- } else {
672
- r .metrics .numTotalFailedNotifications .WithLabelValues (r .integration .Name (), defaultStatusCode ).Inc ()
672
+ result , interErr := getFailureStatusCodeCategory (e .StatusCode )
673
+ if interErr == nil {
674
+ statusCodeCategory = result
675
+ }
673
676
}
674
677
}
678
+ r .metrics .numTotalFailedNotifications .WithLabelValues (r .integration .Name (), statusCodeCategory ).Inc ()
675
679
return ctx , alerts , err
676
680
}
677
681
0 commit comments