Skip to content

Commit 89e1c0d

Browse files
alexander-akhmetovyuri-tceretian
authored andcommitted
Use model.Duration for timeout option in webhook notifier (#117)
1 parent 4519ea7 commit 89e1c0d

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
@@ -598,7 +598,7 @@ type WebhookConfig struct {
598598

599599
// Timeout is the maximum time allowed to invoke the webhook. Setting this to 0
600600
// does not impose a timeout.
601-
Timeout time.Duration `yaml:"timeout" json:"timeout"`
601+
Timeout model.Duration `yaml:"timeout" json:"timeout"`
602602
}
603603

604604
// 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
"go.opentelemetry.io/otel"
@@ -128,7 +129,7 @@ func (n *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, er
128129
}
129130

130131
if n.conf.Timeout > 0 {
131-
postCtx, cancel := context.WithTimeoutCause(ctx, n.conf.Timeout, fmt.Errorf("configured webhook timeout reached (%s)", n.conf.Timeout))
132+
postCtx, cancel := context.WithTimeoutCause(ctx, time.Duration(n.conf.Timeout), fmt.Errorf("configured webhook timeout reached (%s)", n.conf.Timeout))
132133
defer cancel()
133134
ctx = postCtx
134135
}

0 commit comments

Comments
 (0)