Skip to content

Commit

Permalink
fix ReplicaCollector show wrong info
Browse files Browse the repository at this point in the history
  • Loading branch information
junwen12221 committed Feb 15, 2022
1 parent 94cf116 commit ed31db0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions mycat2/src/main/java/io/mycat/exporter/ReplicaCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

public class ReplicaCollector extends Collector {
Expand All @@ -27,9 +24,10 @@ public List<MetricFamilySamples> collect() {

List<Map<String, Object>> resultSetMap = rowBaseIterator.getResultSetMap();
for (Map<String, Object> map : resultSetMap) {
List<String> collect = map.keySet().stream()
.filter(i -> columns.contains(i))
.map(s -> Objects.toString(map.get(s))).collect(Collectors.toList());
List<String> collect = columns.stream()
.map(s -> {
return Optional.ofNullable(map.get(s)).map(i-> Objects.toString(i)).orElse(null);
}).collect(Collectors.toList());
Object available = map.get("AVAILABLE");
int value = (Boolean.parseBoolean(available.toString())) ? 1 : 0;//check the value
gaugeMetricFamily.addMetric(collect, value);
Expand Down

0 comments on commit ed31db0

Please sign in to comment.