nvazquez commented on code in PR #12112:
URL: https://github.com/apache/cloudstack/pull/12112#discussion_r2603754069
##########
plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java:
##########
@@ -512,20 +512,48 @@ public void updateMetrics() {
public String getMetrics() {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("# Cloudstack Prometheus Metrics\n");
- for (final Item item : metricsItems) {
+
+ List<Item> sortedItems = metricsItems.stream()
+ .sorted((item1, item2) -> item1.name.compareTo(item2.name))
+ .collect(Collectors.toList());
+
+ String currentMetricName = null;
+
+ for (Item item : sortedItems) {
+ if (!item.name.equals(currentMetricName)) {
+ currentMetricName = item.name;
+ stringBuilder.append("# HELP
").append(currentMetricName).append(" ")
+ .append(item.getHelp()).append("\n");
Review Comment:
@Sinscerly sorry for the delay. My concern was only for the metrics that
override the `help` field on the `item.toMetricsString()` call.
For example:
On the metrics iteration, when creating the metrics string for `ItemHostCpu`
the string will always start with the default HELP text (`Host CPU usage in
MHz`) despite having tags or not - I see in case the metric contains tags it
should display `Host CPU usage in MHz grouped by host tags`. Please correct me
if I'm wrong
Additionally, I think this if block `if
(!item.name.equals(currentMetricName)) ` can be removed
--
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]