mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
25317b4e70
Signed-off-by: hagen1778 <roman@victoriametrics.com>
36 lines
883 B
Go
36 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),
|
|
}
|
|
}
|