This is an automated email from the ASF dual-hosted git repository.

spricoder pushed a commit to branch fix/metric_default_label_1.2
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 023f5e7a672774f5a71121a1594a6aaeb51e5574
Author: ZhangHongYin <[email protected]>
AuthorDate: Mon Jul 17 19:24:24 2023 +0800

    Fix default label when no tag (#10568)
    
    (cherry picked from commit adea4bb3c3d15c5338e094ff64c639a378aa3698)
---
 .../reporter/prometheus/PrometheusTextWriter.java      | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusTextWriter.java
 
b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusTextWriter.java
index 2ca5076a3df..8311937dafc 100644
--- 
a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusTextWriter.java
+++ 
b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusTextWriter.java
@@ -68,23 +68,23 @@ class PrometheusTextWriter extends FilterWriter {
   public void writeSample(String name, Map<String, String> labels, Object 
value)
       throws IOException {
     write(name);
+    write('{');
+    write("cluster=\"");
+    write(METRIC_CONFIG.getClusterName());
+    write("\",nodeType=\"");
+    write(METRIC_CONFIG.getNodeType().toString());
+    write("\",nodeId=\"");
+    write(String.valueOf(METRIC_CONFIG.getNodeId()));
+    write("\",");
     if (labels.size() > 0) {
-      write('{');
-      write("cluster=\"");
-      write(METRIC_CONFIG.getClusterName());
-      write("\",nodeType=\"");
-      write(METRIC_CONFIG.getNodeType().toString());
-      write("\",nodeId=\"");
-      write(String.valueOf(METRIC_CONFIG.getNodeId()));
-      write("\",");
       for (Map.Entry<String, String> entry : labels.entrySet()) {
         write(entry.getKey());
         write("=\"");
         write(entry.getValue());
         write("\",");
       }
-      write('}');
     }
+    write('}');
     write(' ');
     write(value.toString());
     write('\n');

Reply via email to