Skip to content

Commit

Permalink
Change cardinalityMu to statesMu on alert node
Browse files Browse the repository at this point in the history
  • Loading branch information
desa committed Mar 2, 2017
1 parent 8526f28 commit 381955d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type AlertNode struct {
messageTmpl *text.Template
detailsTmpl *html.Template

cardinalityMu sync.RWMutex
statesMu sync.RWMutex

alertsTriggered *expvar.Int
oksTriggered *expvar.Int
Expand Down Expand Up @@ -451,9 +451,9 @@ func newAlertNode(et *ExecutingTask, n *pipeline.AlertNode, l *log.Logger) (an *

func (a *AlertNode) runAlert([]byte) error {
valueF := func() int64 {
a.cardinalityMu.RLock()
a.statesMu.RLock()
l := len(a.states)
a.cardinalityMu.RUnlock()
a.statesMu.RUnlock()
return int64(l)
}
a.statMap.Set(statCardinalityGauge, expvar.NewIntFuncGauge(valueF))
Expand Down Expand Up @@ -951,9 +951,9 @@ func (a *AlertNode) updateState(t time.Time, level alert.Level, group models.Gro
state = &alertState{
history: make([]alert.Level, a.a.History),
}
a.cardinalityMu.Lock()
a.statesMu.Lock()
a.states[group] = state
a.cardinalityMu.Unlock()
a.statesMu.Unlock()
}
state.addEvent(level)

Expand Down Expand Up @@ -1090,8 +1090,8 @@ func (a *AlertNode) renderMessageAndDetails(id, name string, t time.Time, group
}

func (a *AlertNode) getAlertState(id models.GroupID) (state *alertState, ok bool) {
a.cardinalityMu.RLock()
a.statesMu.RLock()
state, ok = a.states[id]
a.cardinalityMu.RUnlock()
a.statesMu.RUnlock()
return state, ok
}

0 comments on commit 381955d

Please sign in to comment.