From 40e3d664de0909c99e88837064a52161371b2d9d Mon Sep 17 00:00:00 2001 From: majin1102 Date: Sat, 27 Apr 2024 18:35:01 +0800 Subject: [PATCH 1/4] Optimize metrics module, package and class naming --- .../pom.xml | 2 +- .../prometheus-reporter/pom.xml | 2 +- .../metrics/promethues/MetricsCollector.java} | 8 ++++---- .../promethues/PrometheusMetricsReporter.java} | 16 +++++++--------- amoro-ams/pom.xml | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) rename amoro-ams/{amoro-ams-metric-reporter => amoro-ams-metrics}/pom.xml (96%) rename amoro-ams/{amoro-ams-metric-reporter => amoro-ams-metrics}/prometheus-reporter/pom.xml (98%) rename amoro-ams/{amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/MetricCollector.java => amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java} (96%) rename amoro-ams/{amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/PrometheusExporterMetricReporter.java => amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java} (77%) diff --git a/amoro-ams/amoro-ams-metric-reporter/pom.xml b/amoro-ams/amoro-ams-metrics/pom.xml similarity index 96% rename from amoro-ams/amoro-ams-metric-reporter/pom.xml rename to amoro-ams/amoro-ams-metrics/pom.xml index c02e516a65..e12e2d8efa 100644 --- a/amoro-ams/amoro-ams-metric-reporter/pom.xml +++ b/amoro-ams/amoro-ams-metrics/pom.xml @@ -27,7 +27,7 @@ 0.7-SNAPSHOT - amoro-ams-metric-reporter + amoro-ams-metrics pom Amoro Project AMS Metric Reporter Parent https://amoro.apache.org diff --git a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/pom.xml b/amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml similarity index 98% rename from amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/pom.xml rename to amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml index 28aef6118e..40a1c58847 100644 --- a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/pom.xml +++ b/amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml @@ -20,7 +20,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - amoro-ams-metric-reporter + amoro-ams-metrics org.apache.amoro 0.7-SNAPSHOT ../pom.xml diff --git a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/MetricCollector.java b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java similarity index 96% rename from amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/MetricCollector.java rename to amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java index 520d8c75aa..c875fc12b1 100644 --- a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/MetricCollector.java +++ b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.amoro.metrics.reporter.promethues; +package org.apache.amoro.metrics.promethues; import io.prometheus.client.Collector; import org.apache.amoro.api.metrics.Counter; @@ -37,14 +37,14 @@ import java.util.stream.Collectors; /** Metric type converter for prometheus api */ -public class MetricCollector extends Collector { - private static final Logger LOGGER = LoggerFactory.getLogger(MetricCollector.class); +public class MetricsCollector extends Collector { + private static final Logger LOGGER = LoggerFactory.getLogger(MetricsCollector.class); private static final String PREFIX = "amoro_"; private static final Pattern NAME_PATTERN = Pattern.compile("[a-zA-Z_:][a-zA-Z0-9_:]*"); private static final Pattern LABEL_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]*"); MetricSet metrics; - public MetricCollector(MetricSet metrics) { + public MetricsCollector(MetricSet metrics) { this.metrics = metrics; } diff --git a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/PrometheusExporterMetricReporter.java b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java similarity index 77% rename from amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/PrometheusExporterMetricReporter.java rename to amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java index 60b462ebb2..3deac8b595 100644 --- a/amoro-ams/amoro-ams-metric-reporter/prometheus-reporter/src/main/java/org/apache/amoro/metrics/reporter/promethues/PrometheusExporterMetricReporter.java +++ b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.amoro.metrics.reporter.promethues; +package org.apache.amoro.metrics.promethues; import io.prometheus.client.exporter.HTTPServer; import org.apache.amoro.api.metrics.MetricReporter; @@ -27,22 +27,20 @@ import java.util.Optional; /** Prometheus exporter */ -public class PrometheusExporterMetricReporter implements MetricReporter { +public class PrometheusMetricsReporter implements MetricReporter { public static final String PORT = "port"; - private int port; private HTTPServer server; @Override public void open(Map properties) { - this.port = - Optional.ofNullable(properties.get(PORT)) - .map(Integer::valueOf) - .orElseThrow(() -> new IllegalArgumentException("Lack required property: " + PORT)); + int port = Optional.ofNullable(properties.get(PORT)) + .map(Integer::valueOf) + .orElseThrow(() -> new IllegalArgumentException("Lack required property: " + PORT)); try { - this.server = new HTTPServer(this.port); + this.server = new HTTPServer(port); } catch (IOException e) { throw new RuntimeException("Start prometheus exporter server failed.", e); } @@ -60,7 +58,7 @@ public String name() { @Override public void setGlobalMetricSet(MetricSet globalMetricSet) { - MetricCollector collector = new MetricCollector(globalMetricSet); + MetricsCollector collector = new MetricsCollector(globalMetricSet); collector.register(); } } diff --git a/amoro-ams/pom.xml b/amoro-ams/pom.xml index a5af5f8956..f56daf7b06 100644 --- a/amoro-ams/pom.xml +++ b/amoro-ams/pom.xml @@ -37,7 +37,7 @@ amoro-ams-server amoro-ams-dashboard amoro-ams-optimizer - amoro-ams-metric-reporter + amoro-ams-metrics dist From 0fb85790946dbd244e75d843326df7b4abba75a2 Mon Sep 17 00:00:00 2001 From: majin1102 Date: Sat, 27 Apr 2024 19:10:59 +0800 Subject: [PATCH 2/4] mvn spotless apply --- .../metrics/promethues/PrometheusMetricsReporter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java index 3deac8b595..f636ca6865 100644 --- a/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java +++ b/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java @@ -35,9 +35,10 @@ public class PrometheusMetricsReporter implements MetricReporter { @Override public void open(Map properties) { - int port = Optional.ofNullable(properties.get(PORT)) - .map(Integer::valueOf) - .orElseThrow(() -> new IllegalArgumentException("Lack required property: " + PORT)); + int port = + Optional.ofNullable(properties.get(PORT)) + .map(Integer::valueOf) + .orElseThrow(() -> new IllegalArgumentException("Lack required property: " + PORT)); try { this.server = new HTTPServer(port); From 6942aab54372f96dae1377673865d6682cf28873 Mon Sep 17 00:00:00 2001 From: majin1102 Date: Sun, 28 Apr 2024 22:20:50 +0800 Subject: [PATCH 3/4] rename to amoro-metrics-prometheus --- .../{prometheus-reporter => amoro-metrics-prometheus}/pom.xml | 2 +- .../org/apache/amoro/metrics/promethues/MetricsCollector.java | 0 .../amoro/metrics/promethues/PrometheusMetricsReporter.java | 0 amoro-ams/amoro-ams-metrics/pom.xml | 2 +- amoro-ams/dist/pom.xml | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename amoro-ams/amoro-ams-metrics/{prometheus-reporter => amoro-metrics-prometheus}/pom.xml (98%) rename amoro-ams/amoro-ams-metrics/{prometheus-reporter => amoro-metrics-prometheus}/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java (100%) rename amoro-ams/amoro-ams-metrics/{prometheus-reporter => amoro-metrics-prometheus}/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java (100%) diff --git a/amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml b/amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/pom.xml similarity index 98% rename from amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml rename to amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/pom.xml index 40a1c58847..1439a58d65 100644 --- a/amoro-ams/amoro-ams-metrics/prometheus-reporter/pom.xml +++ b/amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/pom.xml @@ -27,7 +27,7 @@ 4.0.0 - prometheus-reporter + amoro-metrics-prometheus Amoro Project AMS Prometheus Reporter https://amoro.apache.org diff --git a/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java b/amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java similarity index 100% rename from amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java rename to amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/src/main/java/org/apache/amoro/metrics/promethues/MetricsCollector.java diff --git a/amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java b/amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java similarity index 100% rename from amoro-ams/amoro-ams-metrics/prometheus-reporter/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java rename to amoro-ams/amoro-ams-metrics/amoro-metrics-prometheus/src/main/java/org/apache/amoro/metrics/promethues/PrometheusMetricsReporter.java diff --git a/amoro-ams/amoro-ams-metrics/pom.xml b/amoro-ams/amoro-ams-metrics/pom.xml index e12e2d8efa..b9ab83fd3f 100644 --- a/amoro-ams/amoro-ams-metrics/pom.xml +++ b/amoro-ams/amoro-ams-metrics/pom.xml @@ -33,7 +33,7 @@ https://amoro.apache.org - prometheus-reporter + amoro-metrics-prometheus diff --git a/amoro-ams/dist/pom.xml b/amoro-ams/dist/pom.xml index 9152baeccd..1232dcfd5f 100644 --- a/amoro-ams/dist/pom.xml +++ b/amoro-ams/dist/pom.xml @@ -60,7 +60,7 @@ org.apache.amoro - prometheus-reporter + amoro-metrics-prometheus ${project.version} compile From a536781e73295106e4b9698b196b01abc9ed888d Mon Sep 17 00:00:00 2001 From: majin1102 Date: Sat, 11 May 2024 00:37:38 +0800 Subject: [PATCH 4/4] Update bin.xml --- amoro-ams/dist/src/main/assemblies/bin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amoro-ams/dist/src/main/assemblies/bin.xml b/amoro-ams/dist/src/main/assemblies/bin.xml index 8630e1cdd1..e7ac120fce 100644 --- a/amoro-ams/dist/src/main/assemblies/bin.xml +++ b/amoro-ams/dist/src/main/assemblies/bin.xml @@ -46,7 +46,7 @@ - ../amoro-ams-metric-reporter/prometheus-reporter/target/prometheus-reporter-${project.version}-jar-with-dependencies.jar + ../amoro-ams-metrics/amoro-metrics-prometheus/target/amoro-metrics-prometheus-${project.version}-jar-with-dependencies.jar plugin/metrics-reporter prometheus-reporter.jar