Skip to content

Commit 1c49704

Browse files
Use model.Duration for timeout option in webhook notifier
Signed-off-by: Alexander Akhmetov <[email protected]>
1 parent 0ce3cfb commit 1c49704

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

config/notifiers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ type WebhookConfig struct {
538538

539539
// Timeout is the maximum time allowed to invoke the webhook. Setting this to 0
540540
// does not impose a timeout.
541-
Timeout time.Duration `yaml:"timeout" json:"timeout"`
541+
Timeout model.Duration `yaml:"timeout" json:"timeout"`
542542
}
543543

544544
// UnmarshalYAML implements the yaml.Unmarshaler interface.

notify/webhook/webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"net/http"
2323
"os"
2424
"strings"
25+
"time"
2526

2627
commoncfg "github.com/prometheus/common/config"
2728

@@ -113,7 +114,7 @@ func (n *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, er
113114
}
114115

115116
if n.conf.Timeout > 0 {
116-
postCtx, cancel := context.WithTimeoutCause(ctx, n.conf.Timeout, fmt.Errorf("configured webhook timeout reached (%s)", n.conf.Timeout))
117+
postCtx, cancel := context.WithTimeoutCause(ctx, time.Duration(n.conf.Timeout), fmt.Errorf("configured webhook timeout reached (%s)", n.conf.Timeout))
117118
defer cancel()
118119
ctx = postCtx
119120
}

0 commit comments

Comments
 (0)