hgruck commented on a change in pull request #2074:
URL: https://github.com/apache/ozone/pull/2074#discussion_r600418739
##########
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<>());
}
- prometheusMetricKey.append("}");
- String prometheusMetricKeyAsString = prometheusMetricKey.toString();
- builder.append(prometheusMetricKeyAsString);
- builder.append(" ");
- builder.append(metrics.value());
- builder.append("\n");
- metricLines.put(prometheusMetricKeyAsString, builder.toString());
+ metricLines.get(metricKey).put(prometheusMetricKeyAsString,
Review comment:
Good idea, I've added the changes in a534cc2.
--
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]