*: Remove .WasInhibited and .WasSilenced fields of Alert type

This commit is contained in:
Frederic Branczyk 2017-10-10 15:49:39 +02:00
parent d47f8b908c
commit 0ef6695055
No known key found for this signature in database
GPG Key ID: 7741A52782A90069
3 changed files with 4 additions and 18 deletions

View File

@ -311,14 +311,11 @@ func NewInhibitStage(m types.Muter, mk types.Marker) *InhibitStage {
func (n *InhibitStage) Exec(ctx context.Context, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
var filtered []*types.Alert
for _, a := range alerts {
_, ok := n.marker.Inhibited(a.Fingerprint())
// TODO(fabxc): increment total alerts counter.
// Do not send the alert if the silencer mutes it.
if !n.muter.Mutes(a.Labels) {
// TODO(fabxc): increment muted alerts counter.
filtered = append(filtered, a)
// Store whether a previously inhibited alert is firing again.
a.WasInhibited = ok
}
}
@ -343,7 +340,6 @@ func NewSilenceStage(s *silence.Silences, mk types.Marker) *SilenceStage {
func (n *SilenceStage) Exec(ctx context.Context, alerts ...*types.Alert) (context.Context, []*types.Alert, error) {
var filtered []*types.Alert
for _, a := range alerts {
_, ok := n.marker.Silenced(a.Fingerprint())
// TODO(fabxc): increment total alerts counter.
// Do not send the alert if the silencer mutes it.
sils, err := n.silences.Query(
@ -358,8 +354,6 @@ func (n *SilenceStage) Exec(ctx context.Context, alerts ...*types.Alert) (contex
// TODO(fabxc): increment muted alerts counter.
filtered = append(filtered, a)
n.marker.SetSilenced(a.Labels.Fingerprint())
// Store whether a previously silenced alert is firing again.
a.WasSilenced = ok
} else {
ids := make([]string, len(sils))
for i, s := range sils {

View File

@ -477,11 +477,8 @@ func TestSilenceStage(t *testing.T) {
}
var got []model.LabelSet
for i, a := range alerts {
for _, a := range alerts {
got = append(got, a.Labels)
if a.WasSilenced != (i == 1) {
t.Errorf("Expected WasSilenced to be %v for %d, was %v", i == 1, i, a.WasSilenced)
}
}
if !reflect.DeepEqual(got, out) {
@ -533,11 +530,8 @@ func TestInhibitStage(t *testing.T) {
}
var got []model.LabelSet
for i, a := range alerts {
for _, a := range alerts {
got = append(got, a.Labels)
if a.WasInhibited != (i == 1) {
t.Errorf("Expected WasInhibited to be %v for %d, was %v", i == 1, i, a.WasInhibited)
}
}
if !reflect.DeepEqual(got, out) {

View File

@ -261,10 +261,8 @@ type Alert struct {
model.Alert
// The authoritative timestamp.
UpdatedAt time.Time
Timeout bool
WasSilenced bool `json:"-"`
WasInhibited bool `json:"-"`
UpdatedAt time.Time
Timeout bool
}
// AlertSlice is a sortable slice of Alerts.