smallzhongfeng commented on code in PR #812:
URL: https://github.com/apache/incubator-uniffle/pull/812#discussion_r1166247442


##########
common/src/main/java/org/apache/uniffle/common/metrics/MetricsManager.java:
##########
@@ -17,27 +17,34 @@
 
 package org.apache.uniffle.common.metrics;
 
+import java.util.Map;
+
+import com.google.common.collect.Maps;
 import io.prometheus.client.CollectorRegistry;
 import io.prometheus.client.Counter;
 import io.prometheus.client.Gauge;
 import io.prometheus.client.Histogram;
 import io.prometheus.client.Summary;
 
 public class MetricsManager {
-  private CollectorRegistry collectorRegistry;
+  private final CollectorRegistry collectorRegistry;
+  private final String[] defaultLabelNames;
+  private final String[] defaultLabelValues;
   private static final double[] QUANTILES = {0.50, 0.75, 0.90, 0.95, 0.99};
   private static final double QUANTILE_ERROR = 0.01;
 
   public MetricsManager() {
-    this(null);
+    this(null, Maps.newHashMap());
   }
 
-  public MetricsManager(CollectorRegistry collectorRegistry) {
+  public MetricsManager(CollectorRegistry collectorRegistry, Map<String, 
String> defaultLabels) {
     if (collectorRegistry == null) {
       this.collectorRegistry = CollectorRegistry.defaultRegistry;
     } else {
       this.collectorRegistry = collectorRegistry;
     }
+    this.defaultLabelNames = defaultLabels.keySet().toArray(new String[0]);
+    this.defaultLabelValues = defaultLabels.values().toArray(new String[0]);

Review Comment:
   For this `TreeMap class, make specific guarantees as to their order; others, 
like the HashMap class, do not.` I think this just means that the order of 
`map.Entry` is unstable, but the key and value are still one-on-one. As long as 
we can ensure that the one-on-one relationship is correct, it seems unnecessary 
to ensure the order of `map.Entry`



##########
common/src/main/java/org/apache/uniffle/common/metrics/MetricsManager.java:
##########
@@ -17,27 +17,34 @@
 
 package org.apache.uniffle.common.metrics;
 
+import java.util.Map;
+
+import com.google.common.collect.Maps;
 import io.prometheus.client.CollectorRegistry;
 import io.prometheus.client.Counter;
 import io.prometheus.client.Gauge;
 import io.prometheus.client.Histogram;
 import io.prometheus.client.Summary;
 
 public class MetricsManager {
-  private CollectorRegistry collectorRegistry;
+  private final CollectorRegistry collectorRegistry;
+  private final String[] defaultLabelNames;
+  private final String[] defaultLabelValues;
   private static final double[] QUANTILES = {0.50, 0.75, 0.90, 0.95, 0.99};
   private static final double QUANTILE_ERROR = 0.01;
 
   public MetricsManager() {
-    this(null);
+    this(null, Maps.newHashMap());
   }
 
-  public MetricsManager(CollectorRegistry collectorRegistry) {
+  public MetricsManager(CollectorRegistry collectorRegistry, Map<String, 
String> defaultLabels) {
     if (collectorRegistry == null) {
       this.collectorRegistry = CollectorRegistry.defaultRegistry;
     } else {
       this.collectorRegistry = collectorRegistry;
     }
+    this.defaultLabelNames = defaultLabels.keySet().toArray(new String[0]);
+    this.defaultLabelValues = defaultLabels.values().toArray(new String[0]);

Review Comment:
   OK for me.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to