elek commented on a change in pull request #2074:
URL: https://github.com/apache/ozone/pull/2074#discussion_r599611346



##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/PrometheusMetricsSink.java
##########
@@ -64,43 +66,48 @@ public void putMetrics(MetricsRecord metricsRecord) {
         String key = prometheusName(
             metricsRecord.name(), metrics.name());
 
-        StringBuilder builder = new StringBuilder();
-        builder.append("# TYPE ")
-            .append(key)
-            .append(" ")
-            .append(metrics.type().toString().toLowerCase())
-            .append("\n");
-
-        StringBuilder prometheusMetricKey = new StringBuilder();
-        prometheusMetricKey.append(key)
-            .append("{");
-        String sep = "";
-
-        //add tags
-        for (MetricsTag tag : metricsRecord.tags()) {
-          String tagName = tag.name().toLowerCase();
-
-          //ignore specific tag which includes sub-hierarchy
-          if (!tagName.equals("numopenconnectionsperuser")) {
-            prometheusMetricKey.append(sep)
-                .append(tagName)
-                .append("=\"")
-                .append(tag.value())
-                .append("\"");
-            sep = ",";
-          }
+        String prometheusMetricKeyAsString =
+            getPrometheusMetricKeyAsString(metricsRecord, key);
+
+        String metricKey = "# TYPE "
+            + key
+            + " "
+            + metrics.type().toString().toLowerCase();
+
+        if (!metricLines.containsKey(metricKey)){
+          metricLines.put(metricKey, new TreeMap<>());

Review comment:
       ```suggestion
             metricLines.put(metricKey, Collections.synchronizedSortedMap(new 
TreeMap<>()));
   ```
   
   Fix me if I am wrong, but I think the sub maps should also be synchronized.




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

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