This is an automated email from the ASF dual-hosted git repository. jt2594838 pushed a commit to branch optimize_prometheus_report in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 17c11517eb41aaaaa6e85d5aa84b9ef8b8a9934f Author: Tian Jiang <[email protected]> AuthorDate: Tue Sep 1 18:11:27 2026 +0800 fix compilation --- .../apache/iotdb/metrics/config/MetricConfigDescriptor.java | 12 ++++-------- .../org/apache/iotdb/metrics/config/MetricConfigTest.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java index d7a08a09a54..113bff7ebcc 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfigDescriptor.java @@ -132,7 +132,7 @@ public class MetricConfigDescriptor { loadConfig.setPrometheusReporterAsyncUpdate( Boolean.parseBoolean( getPrometheusReporterAsyncUpdateProperty( - properties, isConfigNode, loadConfig.isPrometheusReporterAsyncUpdate()))); + properties, prefix, loadConfig.isPrometheusReporterAsyncUpdate()))); loadConfig.setPrometheusReporterUsername( getPropertyWithoutPrefix( @@ -228,21 +228,17 @@ public class MetricConfigDescriptor { } private String getPrometheusReporterAsyncUpdateProperty( - Properties properties, boolean isConfigNode, boolean defaultValue) { + Properties properties, String prefix, boolean defaultValue) { String value = properties.getProperty("prometheus_reporter_async_update"); if (value == null) { // Keep accepting the metric-prefixed forms for compatibility with node-specific configs. value = properties.getProperty("metric_prometheus_reporter_async_update"); } if (value == null) { - value = - properties.getProperty( - (isConfigNode ? "cn_" : "dn_") + "prometheus_reporter_async_update"); + value = properties.getProperty(prefix + "prometheus_reporter_async_update"); } if (value == null) { - value = - properties.getProperty( - (isConfigNode ? "cn_" : "dn_") + "metric_prometheus_reporter_async_update"); + value = properties.getProperty(prefix + "metric_prometheus_reporter_async_update"); } return value == null ? String.valueOf(defaultValue) : value.trim(); } diff --git a/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java b/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java index 3654010c4f6..3d1d3a0b0cf 100644 --- a/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java +++ b/iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/config/MetricConfigTest.java @@ -107,4 +107,16 @@ public class MetricConfigTest { assertEquals(5, (int) reporterConfig.getPushPeriodInSecond()); assertEquals(InternalReporterType.IOTDB, metricConfig.getInternalReportType()); } + + @Test + public void testMetricConfigWithCustomNodePrefix() { + Properties properties = new Properties(); + properties.setProperty("sn_metric_prometheus_reporter_async_update", "false"); + + MetricConfigDescriptor.getInstance().loadProps(properties, "sn_"); + + assertEquals( + false, + MetricConfigDescriptor.getInstance().getMetricConfig().isPrometheusReporterAsyncUpdate()); + } }
