some minor fixes: (#5535)

1. If alerts is empty after `relabelAlerts`, just return to avoid
subsequent unnecessary operations

2. minor fix in notifier's test case

3. minor fix in comment

Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
This commit is contained in:
Yao Zengzeng 2019-05-06 15:02:40 +08:00 committed by Brian Brazil
parent 5544cb252a
commit dbd7a7400e
2 changed files with 5 additions and 2 deletions

View File

@ -364,6 +364,9 @@ func (n *Manager) Send(alerts ...*Alert) {
}
alerts = n.relabelAlerts(alerts)
if len(alerts) == 0 {
return
}
// Queue capacity should be significantly larger than a single alert
// batch could be.
@ -615,7 +618,7 @@ func postPath(pre string) string {
return path.Join("/", pre, alertPushEndpoint)
}
// alertmanagersFromGroup extracts a list of alertmanagers from a target group
// alertmanagerFromGroup extracts a list of alertmanagers from a target group
// and an associated AlertmanagerConfig.
func alertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig) ([]alertmanager, []alertmanager, error) {
var res []alertmanager

View File

@ -385,7 +385,7 @@ func TestHandlerQueueing(t *testing.T) {
expected = alerts[:maxBatchSize]
unblock <- struct{}{}
for i := 2; i < 4; i++ {
for i := 2; i < 5; i++ {
select {
case <-called:
expected = alerts[i*maxBatchSize : (i+1)*maxBatchSize]