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


##########
common/src/main/java/org/apache/uniffle/common/metrics/MetricsManager.java:
##########
@@ -52,6 +54,10 @@ public Counter addCounter(String name, String help, String[] 
labels) {
     return 
Counter.build().name(name).labelNames(labels).help(help).register(collectorRegistry);
   }
 
+  public Counter addCounterWithTags(String name) {
+    return addCounter(name, Constants.SHUFFLE_SERVER_TAGS);
+  }
+
   public Gauge addGauge(String name, String... labels) {

Review Comment:
   ```
     private String[] defaultLabelNames;
     private String[] defaultLabelValues;
     public MetricsManager() {
       this(null, Maps.newHashMap());
     }
   
     public MetricsManager(CollectorRegistry collectorRegistry, Map<String, 
String> defaultLabels) {
       if (collectorRegistry == null) {
         this.collectorRegistry = CollectorRegistry.defaultRegistry;
       } else {
         this.collectorRegistry = collectorRegistry;
       }
   
       this.defaultLabelNames = defaultLabels.entrySet().stream()
                                    .map(Map.Entry::getKey)
                                    .toArray(String[]::new);
       this.defaultLabelValues = defaultLabels.entrySet().stream()
                                    .map(Map.Entry::getValue)
                                    .toArray(String[]::new);
     }
   
     public Counter.Child addLabeledCounter(String name) {
       Counter c = addCounter(name, "counter " + name, this.defaultLabelNames);
       return c.labels(this.defaultLabelValues);
     }
   ```
   
   How about the above one? The labeled Counter, Gauge etc. would be created in 
the metrics manager. 
   
   It would reduce the code changes in this PR.



-- 
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