mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
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:
parent
5544cb252a
commit
dbd7a7400e
|
@ -364,6 +364,9 @@ func (n *Manager) Send(alerts ...*Alert) {
|
||||||
}
|
}
|
||||||
|
|
||||||
alerts = n.relabelAlerts(alerts)
|
alerts = n.relabelAlerts(alerts)
|
||||||
|
if len(alerts) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Queue capacity should be significantly larger than a single alert
|
// Queue capacity should be significantly larger than a single alert
|
||||||
// batch could be.
|
// batch could be.
|
||||||
|
@ -615,7 +618,7 @@ func postPath(pre string) string {
|
||||||
return path.Join("/", pre, alertPushEndpoint)
|
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.
|
// and an associated AlertmanagerConfig.
|
||||||
func alertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig) ([]alertmanager, []alertmanager, error) {
|
func alertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig) ([]alertmanager, []alertmanager, error) {
|
||||||
var res []alertmanager
|
var res []alertmanager
|
||||||
|
|
|
@ -385,7 +385,7 @@ func TestHandlerQueueing(t *testing.T) {
|
||||||
expected = alerts[:maxBatchSize]
|
expected = alerts[:maxBatchSize]
|
||||||
unblock <- struct{}{}
|
unblock <- struct{}{}
|
||||||
|
|
||||||
for i := 2; i < 4; i++ {
|
for i := 2; i < 5; i++ {
|
||||||
select {
|
select {
|
||||||
case <-called:
|
case <-called:
|
||||||
expected = alerts[i*maxBatchSize : (i+1)*maxBatchSize]
|
expected = alerts[i*maxBatchSize : (i+1)*maxBatchSize]
|
||||||
|
|
Loading…
Reference in a new issue