Fix #6382
This commit is contained in:
@ -19,12 +19,15 @@ package org.apache.doris.metric;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DorisMetricRegistry {
|
||||
|
||||
private List<Metric> paloMetrics = Lists.newArrayList();
|
||||
private Collection<Metric> paloMetrics = new PriorityQueue<>(Comparator.comparing(Metric::getName));
|
||||
|
||||
public DorisMetricRegistry() {
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.doris.metric;
|
||||
|
||||
|
||||
import org.apache.doris.alter.Alter;
|
||||
import org.apache.doris.alter.AlterJob.JobType;
|
||||
import org.apache.doris.catalog.Catalog;
|
||||
|
||||
@ -28,8 +28,10 @@ import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Snapshot;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
@ -54,6 +56,7 @@ public class PrometheusMetricVisitor extends MetricVisitor {
|
||||
|
||||
private int ordinal = 0;
|
||||
private int metricNumber = 0;
|
||||
private Set<String> metricNames = new HashSet();
|
||||
|
||||
public PrometheusMetricVisitor(String prefix) {
|
||||
super(prefix);
|
||||
@ -147,8 +150,11 @@ public class PrometheusMetricVisitor extends MetricVisitor {
|
||||
public void visit(StringBuilder sb, @SuppressWarnings("rawtypes") Metric metric) {
|
||||
// title
|
||||
final String fullName = prefix + "_" + metric.getName();
|
||||
sb.append(HELP).append(fullName).append(" ").append(metric.getDescription()).append("\n");
|
||||
sb.append(TYPE).append(fullName).append(" ").append(metric.getType().name().toLowerCase()).append("\n");
|
||||
if (!metricNames.contains(fullName)) {
|
||||
sb.append(HELP).append(fullName).append(" ").append(metric.getDescription()).append("\n");
|
||||
sb.append(TYPE).append(fullName).append(" ").append(metric.getType().name().toLowerCase()).append("\n");
|
||||
metricNames.add(fullName);
|
||||
}
|
||||
sb.append(fullName);
|
||||
|
||||
// name
|
||||
|
||||
Reference in New Issue
Block a user