VictoriaMetrics/app/vmalert/notifier/notifier_blackhole.go
Roman Khavronenko 25317b4e70
vmalert: follow-up after d4ac4b7813 (#4659)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
2023-07-18 15:53:37 +02:00

37 lines
883 B
Go

package notifier
import "context"
// blackHoleNotifier is a Notifier stub, used when no notifications need
// to be sent.
type blackHoleNotifier struct {
addr string
metrics *metrics
}
// Send will send no notifications, but increase the metric.
func (bh *blackHoleNotifier) Send(_ context.Context, alerts []Alert, _ map[string]string) error { //nolint:revive
bh.metrics.alertsSent.Add(len(alerts))
return nil
}
// Addr of black hole notifier
func (bh blackHoleNotifier) Addr() string {
return bh.addr
}
// Close unregister the metrics
func (bh *blackHoleNotifier) Close() {
bh.metrics.alertsSent.Unregister()
bh.metrics.alertsSendErrors.Unregister()
}
// newBlackHoleNotifier creates a new blackHoleNotifier
func newBlackHoleNotifier() *blackHoleNotifier {
address := "blackhole"
return &blackHoleNotifier{
addr: address,
metrics: newMetrics(address),
}
}