Skip to content

Commit

Permalink
Fix blacklist rule metric name
Browse files Browse the repository at this point in the history
  • Loading branch information
diwanshu-crm committed Aug 24, 2023
1 parent 71a5966 commit 318032d
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
* List of metrics that should receive special treatment (used for blocking or allowing metric names).
Expand Down Expand Up @@ -171,16 +172,16 @@ public void reload()

private List<Pair<Pattern, Counter>> parseConfig(List<String> lines)
{
List<Pair<Pattern, Counter>> patternCounterPairs = new ArrayList<>();
// Create an empty list to hold pairs of Pattern and Counter
List<Pair<Pattern, Counter>> patternCounterPairs = lines.stream()
.map(String::trim)
.filter(line -> line.length() > 0 && !line.startsWith("#"))
.map(line -> {
Pattern pattern = Pattern.compile(line);
Counter counter = metricRegistry.counter( MetricRegistry.name( name, "blacklist" ) );
return Pair.of(pattern, counter); // Create and return the Pair
})
.collect(Collectors.toList());
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
if (!line.isEmpty() && !line.startsWith("#")) {
Pattern pattern = Pattern.compile(line);
Counter counter = metricRegistry.counter( MetricRegistry.name( name, "blacklist-" + (i + 1) ) );
patternCounterPairs.add(Pair.of(pattern, counter)); // Create and return the Pair
}
}

// Reset the counters here if needed
for (Pair<Pattern, Counter> pair : patternCounterPairs) {
Expand Down

0 comments on commit 318032d

Please sign in to comment.