Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/thanos/rule.go: simplify deduplication #1965

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,18 +704,16 @@ func labelsTSDBToProm(lset labels.Labels) (res labels.Labels) {

func removeDuplicateQueryAddrs(logger log.Logger, duplicatedQueriers prometheus.Counter, addrs []string) []string {
set := make(map[string]struct{})
deduplicated := make([]string, 0, len(addrs))
for _, addr := range addrs {
if _, ok := set[addr]; ok {
level.Warn(logger).Log("msg", "duplicate query address is provided - %v", addr)
duplicatedQueriers.Inc()
continue
}
deduplicated = append(deduplicated, addr)
set[addr] = struct{}{}
}

deduplicated := make([]string, 0, len(set))
for key := range set {
deduplicated = append(deduplicated, key)
}
return deduplicated
}

Expand Down