From 26301b4f633b284b1e6d5f508f6604ce45df869e Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 23 Oct 2024 10:03:10 +0200 Subject: [PATCH 01/24] Fill in template I --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- .github/ISSUE_TEMPLATE/enhancement.yml | 2 +- .github/ISSUE_TEMPLATE/question.yml | 2 +- .run/Run Demo.run.xml | 2 +- CONTRIBUTING.md | 4 ++-- README.md | 12 ++++++------ SECURITY.md | 2 +- pom.xml | 6 +++--- renovate.json5 | 2 +- template-placeholder-demo/pom.xml | 6 +++--- template-placeholder/pom.xml | 12 ++++++------ 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 68299d5..3072ce7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -14,9 +14,9 @@ body: attributes: label: "Checklist" options: - - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)" + - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/releases/latest)" required: true - - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues) or [closed](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." required: true - label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise." required: true diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index 7523129..66bb566 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -12,7 +12,7 @@ body: attributes: label: "Checklist" options: - - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues) or [closed](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." required: true - label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise." required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 6ecd6ad..9d2d5cb 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -12,7 +12,7 @@ body: attributes: label: "Checklist" options: - - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." + - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues) or [closed](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to." required: true - label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise." required: true diff --git a/.run/Run Demo.run.xml b/.run/Run Demo.run.xml index 5fb2bc2..92786fc 100644 --- a/.run/Run Demo.run.xml +++ b/.run/Run Demo.run.xml @@ -1,7 +1,7 @@ - org.apache.maven.plugins - maven-assembly-plugin - 3.7.1 + org.springframework.boot + spring-boot-maven-plugin + ${org.springframework.boot.version} - - - ${mainClass} - - - true - - - - jar-with-dependencies - - false + ${mainClass} - make-assembly - package + repackage - single + repackage + package From 42196d3a6ac9d49b66a1cd8bf13b6abbca1bb182 Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 23 Oct 2024 14:25:49 +0200 Subject: [PATCH 10/24] Update pom.xml --- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 5f43121..514fba2 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -60,7 +60,7 @@ io.prometheus prometheus-metrics-shaded-protobuf - + com.google.protobuf protobuf-java From 3e8d37a547087c0412d9f487ce80fd051d83a299 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Fri, 25 Oct 2024 02:33:41 +0000 Subject: [PATCH 11/24] Update org.springframework.boot.version to v3.3.5 --- prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 7ce7c82..9802f54 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -28,7 +28,7 @@ software.xdev.Application - 3.3.4 + 3.3.5 From ece4275f0b98cd7415989e1dacbdc8e877641517 Mon Sep 17 00:00:00 2001 From: AB Date: Fri, 22 Nov 2024 13:59:55 +0100 Subject: [PATCH 12/24] Shade ``io.prometheus:prometheus-metrics-exposition-formats`` into jar and remove protobuf --- CHANGELOG.md | 6 ++ README.md | 10 +++- pom.xml | 2 +- .../pom.xml | 6 +- .../pom.xml | 58 ++++++++++++++----- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d5441b..689d313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,8 @@ +# 2.0.0 +* Make exclusion work in ``prometheus-metrics-exposition-formats`` 1.3.2+ #3 + * ``prometheus-metrics-exposition-formats`` is now directly included using shading + * All protobuf code is removed during shading + * This is a workaround until https://github.com/prometheus/client_java/pull/1190 is merged + # 1.0.0 _Initial release_ diff --git a/README.md b/README.md index 69ad273..2d8eec9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This module is designed to integrate with [Spring Boot Actuator (Prometheus)](ht 1. [Prometheus Protobuf format is obsolete/experimental](https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#protobuf-format), the chance that it's used is near 0 2. The additional library can result in additional attack vectors. For example in [CVE-2024-7254](https://github.com/protocolbuffers/protobuf/security/advisories/GHSA-735f-pc8j-v9w8) - * If the dependency is [reshaded](https://maven.apache.org/plugins/maven-shade-plugin/) it may not be detected by vulnerability scanners (as is the case in ``prometheus.io:prometheus-metrics-exposition-formats <= 1.3.1``) + * If the dependency is [reshaded](https://maven.apache.org/plugins/maven-shade-plugin/) it may not be detected by vulnerability scanners (as is the case in ``io.prometheus:prometheus-metrics-exposition-formats <= 1.3.1``) 3. The protobuf dependency is huge (around 10x bigger) in comparison to the other libraries _See also [prometheus/client_java#1173](https://github.com/prometheus/client_java/issues/1173)_ @@ -20,6 +20,14 @@ _See also [prometheus/client_java#1173](https://github.com/prometheus/client_jav ## Installation [Installation guide for the latest release](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/releases/latest#Installation) +### Compatibility with ``io.prometheus:prometheus-metrics-exposition-formats`` + +| ``io.prometheus:prometheus-metrics-exposition-formats`` version | ``prometheus-metrics-exposition-formats-no-protobuf`` version | +| --- | --- | +| [Upcoming](https://github.com/prometheus/client_java/pull/1190) | No longer required | +| 1.3.2+ | ``2`` | +| < 1.3.2 | ``1`` | + ### Spring Boot Actuator ```xml diff --git a/pom.xml b/pom.xml index 21c1da5..e12e1bc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 1.0.1-SNAPSHOT + 2.0.0-SNAPSHOT pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 9802f54..aca3209 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 1.0.1-SNAPSHOT + 2.0.0-SNAPSHOT prometheus-metrics-exposition-formats-no-protobuf-demo - 1.0.1-SNAPSHOT + 2.0.0-SNAPSHOT jar @@ -28,7 +28,7 @@ software.xdev.Application - 3.3.5 + 3.4.0 diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 0a46370..b1cfa1b 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 1.0.1-SNAPSHOT + 2.0.0-SNAPSHOT jar prometheus-metrics-exposition-formats-no-protobuf @@ -53,19 +53,7 @@ io.prometheus prometheus-metrics-exposition-formats - 1.3.2 - - - - io.prometheus - prometheus-metrics-shaded-protobuf - - - - com.google.protobuf - protobuf-java - - + 1.3.3 @@ -167,7 +155,7 @@ attach-javadocs - verify + package jar @@ -185,13 +173,51 @@ attach-sources - verify + package jar-no-fork + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.0 + + + package + + shade + + + + true + + true + true + + + io.prometheus:prometheus-metrics-exposition-formats + + + + + io.prometheus:prometheus-metrics-exposition-formats + + META-INF/** + io/prometheus/metrics/shaded/** + io/prometheus/metrics/expositionformats/generated/** + io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.* + + + + + + + + From 43223f9000efc654ceaac0ae005105c61e6de1d2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 22 Nov 2024 13:05:26 +0000 Subject: [PATCH 13/24] Release 2.0.0 --- pom.xml | 2 +- .../pom.xml | 4 ++-- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e12e1bc..891188a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.0-SNAPSHOT + 2.0.0 pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index aca3209..312d25d 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.0-SNAPSHOT + 2.0.0 prometheus-metrics-exposition-formats-no-protobuf-demo - 2.0.0-SNAPSHOT + 2.0.0 jar diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index b1cfa1b..7309d95 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 2.0.0-SNAPSHOT + 2.0.0 jar prometheus-metrics-exposition-formats-no-protobuf From 1d1eb717126163ee85765340a93aa16e086b111f Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 22 Nov 2024 13:15:44 +0000 Subject: [PATCH 14/24] Preparing for next development iteration --- pom.xml | 2 +- .../pom.xml | 4 ++-- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 891188a..8d612d6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.0 + 2.0.1-SNAPSHOT pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 312d25d..a9f1a84 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.0 + 2.0.1-SNAPSHOT prometheus-metrics-exposition-formats-no-protobuf-demo - 2.0.0 + 2.0.1-SNAPSHOT jar diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 7309d95..98514d6 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 2.0.0 + 2.0.1-SNAPSHOT jar prometheus-metrics-exposition-formats-no-protobuf From e7db327e48ec5b22ddc7c0112f975e52a12ef9f1 Mon Sep 17 00:00:00 2001 From: Alex B <45384811+AB-xdev@users.noreply.github.com> Date: Mon, 2 Dec 2024 08:50:24 +0100 Subject: [PATCH 15/24] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d8eec9..e148384 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ _See also [prometheus/client_java#1173](https://github.com/prometheus/client_jav | ``io.prometheus:prometheus-metrics-exposition-formats`` version | ``prometheus-metrics-exposition-formats-no-protobuf`` version | | --- | --- | -| [Upcoming](https://github.com/prometheus/client_java/pull/1190) | No longer required | +| 1.3.4+ | [No longer required](https://prometheus.github.io/client_java/exporters/formats/#exclude-protobuf-exposition-format) | | 1.3.2+ | ``2`` | | < 1.3.2 | ``1`` | From a0cf77b5a6cbaeefc596f428254f41c37d8f7efc Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 15 Jan 2025 09:22:00 +0100 Subject: [PATCH 16/24] Adapt changes for 1.3.4+ and add tests --- CHANGELOG.md | 6 ++ README.md | 2 +- .../pom.xml | 47 ++++---------- .../expositionformats/ExpositionFormats.java | 62 +++++++++++++++++++ .../PrometheusProtobufWriter.java | 2 +- .../ExpositionFormatsTest.java | 40 ++++++++++++ 6 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java create mode 100644 prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 689d313..5a9d011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 3.0.0 +* In theory the library is [no longer required](https://prometheus.github.io/client_java/exporters/formats/#exclude-protobuf-exposition-format), however [there are still some problems with how the changes have been implemented upstream](https://github.com/xdev-software/prometheus-metrics-exposition-formats-no-protobuf/issues/27). + * Library now completely removes protobuf functionality + * ``PrometheusProtobufWriter`` is no longer loaded in the first place + * Removed shading once again + # 2.0.0 * Make exclusion work in ``prometheus-metrics-exposition-formats`` 1.3.2+ #3 * ``prometheus-metrics-exposition-formats`` is now directly included using shading diff --git a/README.md b/README.md index e148384..16ebd1c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ _See also [prometheus/client_java#1173](https://github.com/prometheus/client_jav | ``io.prometheus:prometheus-metrics-exposition-formats`` version | ``prometheus-metrics-exposition-formats-no-protobuf`` version | | --- | --- | -| 1.3.4+ | [No longer required](https://prometheus.github.io/client_java/exporters/formats/#exclude-protobuf-exposition-format) | +| 1.3.4+ | [``3`` (optional)](./CHANGELOG.md#300) | | 1.3.2+ | ``2`` | | < 1.3.2 | ``1`` | diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 9a66aaa..3ebd1de 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -52,8 +52,15 @@ io.prometheus - prometheus-metrics-exposition-formats - 1.3.3 + prometheus-metrics-exposition-textformats + 1.3.5 + + + + org.junit.jupiter + junit-jupiter + 5.11.3 + test @@ -183,40 +190,8 @@ org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - package - - shade - - - - true - - true - true - - - io.prometheus:prometheus-metrics-exposition-formats - - - - - io.prometheus:prometheus-metrics-exposition-formats - - META-INF/** - io/prometheus/metrics/shaded/** - io/prometheus/metrics/expositionformats/generated/** - io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.* - - - - - - - + maven-surefire-plugin + 3.5.1 diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java new file mode 100644 index 0000000..57cf3df --- /dev/null +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java @@ -0,0 +1,62 @@ +package io.prometheus.metrics.expositionformats; + +import io.prometheus.metrics.config.ExporterProperties; +import io.prometheus.metrics.config.PrometheusProperties; + + +/** + * Fork of original. Disables Protobuf completely + */ +@SuppressWarnings({"checkstyle:FinalClass", "unused"}) +public class ExpositionFormats +{ + private final PrometheusTextFormatWriter prometheusTextFormatWriter; + private final OpenMetricsTextFormatWriter openMetricsTextFormatWriter; + + private ExpositionFormats( + final PrometheusProtobufWriter prometheusProtobufWriter, // Ignored + final PrometheusTextFormatWriter prometheusTextFormatWriter, + final OpenMetricsTextFormatWriter openMetricsTextFormatWriter) + { + this.prometheusTextFormatWriter = prometheusTextFormatWriter; + this.openMetricsTextFormatWriter = openMetricsTextFormatWriter; + } + + public static ExpositionFormats init() + { + return init(PrometheusProperties.get().getExporterProperties()); + } + + public static ExpositionFormats init(final ExporterProperties properties) + { + return new ExpositionFormats( + null, + new PrometheusTextFormatWriter(properties.getIncludeCreatedTimestamps()), + new OpenMetricsTextFormatWriter( + properties.getIncludeCreatedTimestamps(), properties.getExemplarsOnAllMetricTypes())); + } + + public ExpositionFormatWriter findWriter(final String acceptHeader) + { + if(this.openMetricsTextFormatWriter.accepts(acceptHeader)) + { + return this.openMetricsTextFormatWriter; + } + return this.prometheusTextFormatWriter; + } + + public PrometheusProtobufWriter getPrometheusProtobufWriter() + { + return null; + } + + public PrometheusTextFormatWriter getPrometheusTextFormatWriter() + { + return this.prometheusTextFormatWriter; + } + + public OpenMetricsTextFormatWriter getOpenMetricsTextFormatWriter() + { + return this.openMetricsTextFormatWriter; + } +} diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java index 80bb9a5..fc09e37 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/PrometheusProtobufWriter.java @@ -22,7 +22,7 @@ /** - * Fork of original that removes Protobuf + * Fork of original. Removes Protobuf */ @SuppressWarnings("unused") public class PrometheusProtobufWriter implements ExpositionFormatWriter diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java b/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java new file mode 100644 index 0000000..c6c5fba --- /dev/null +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java @@ -0,0 +1,40 @@ +package io.prometheus.metrics.expositionformats; + +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; + +import io.prometheus.metrics.config.ExporterProperties; + + +class ExpositionFormatsTest +{ + static final String OPENMETRICS_HEADER = "application/openmetrics-text"; + static final String PROTOBUF_HEADER = + "application/vnd.google.protobuf,proto=io.prometheus.client.MetricFamily"; + + @Test + void checkFunctionality() + { + final ExpositionFormats expositionFormats = assertDoesNotThrow(() -> + ExpositionFormats.init(ExporterProperties.builder().build())); + + assertAll( + () -> assertNull(expositionFormats.getPrometheusProtobufWriter()), + () -> assertNotNull(expositionFormats.getOpenMetricsTextFormatWriter()), + () -> assertNotNull(expositionFormats.getPrometheusTextFormatWriter()), + () -> assertEquals( + expositionFormats.getOpenMetricsTextFormatWriter(), + expositionFormats.findWriter(OPENMETRICS_HEADER)), + () -> assertEquals( + expositionFormats.getPrometheusTextFormatWriter(), + expositionFormats.findWriter("")), + () -> assertFalse(expositionFormats.findWriter(PROTOBUF_HEADER) instanceof PrometheusProtobufWriter) + ); + } +} From 8d71920481c742b890769f95f8cbfcc47992aaef Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 15 Jan 2025 09:22:22 +0100 Subject: [PATCH 17/24] Bump version --- pom.xml | 2 +- .../pom.xml | 4 ++-- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 93641f9..556af98 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.1-SNAPSHOT + 3.0.0-SNAPSHOT pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index a9f1a84..0080d16 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 2.0.1-SNAPSHOT + 3.0.0-SNAPSHOT prometheus-metrics-exposition-formats-no-protobuf-demo - 2.0.1-SNAPSHOT + 3.0.0-SNAPSHOT jar diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 3ebd1de..dd07faf 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 2.0.1-SNAPSHOT + 3.0.0-SNAPSHOT jar prometheus-metrics-exposition-formats-no-protobuf From 286ac9abe3929b7b00f8ae41538979f0ceeaf973 Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 15 Jan 2025 09:23:34 +0100 Subject: [PATCH 18/24] Add missing headers --- .../expositionformats/ExpositionFormats.java | 15 +++++++++++++++ .../expositionformats/ExpositionFormatsTest.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java index 57cf3df..5bb2e14 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package io.prometheus.metrics.expositionformats; import io.prometheus.metrics.config.ExporterProperties; diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java b/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java index c6c5fba..b20af78 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java @@ -1,3 +1,18 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package io.prometheus.metrics.expositionformats; import static org.junit.jupiter.api.Assertions.assertAll; From d2c0d6436eb0b76b8ce3fec3928bc1405ed7e604 Mon Sep 17 00:00:00 2001 From: AB Date: Wed, 15 Jan 2025 09:26:27 +0100 Subject: [PATCH 19/24] Suppress --- .../metrics/expositionformats/ExpositionFormats.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java index 5bb2e14..cb44731 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java +++ b/prometheus-metrics-exposition-formats-no-protobuf/src/main/java/io/prometheus/metrics/expositionformats/ExpositionFormats.java @@ -22,7 +22,11 @@ /** * Fork of original. Disables Protobuf completely */ -@SuppressWarnings({"checkstyle:FinalClass", "unused"}) +@SuppressWarnings({ + "checkstyle:FinalClass", + "unused", + "java:S1172", + "PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal"}) public class ExpositionFormats { private final PrometheusTextFormatWriter prometheusTextFormatWriter; From 571efefae735c079b25f8d4f23cf7ce41d65a399 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Wed, 15 Jan 2025 08:32:21 +0000 Subject: [PATCH 20/24] Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.5.2 --- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 1e2e108..8ada84e 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -191,7 +191,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.1 + 3.5.2 From c07326f1f1b1264224ce739191a6bd9cf7a5214c Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Wed, 15 Jan 2025 08:32:22 +0000 Subject: [PATCH 21/24] Update dependency org.junit.jupiter:junit-jupiter to v5.11.4 --- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 1e2e108..540a563 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -59,7 +59,7 @@ org.junit.jupiter junit-jupiter - 5.11.3 + 5.11.4 test From ce0ce1558035b77deefac744a1a8cfd1b606b4c4 Mon Sep 17 00:00:00 2001 From: XDEV Renovate Bot Date: Wed, 15 Jan 2025 08:32:23 +0000 Subject: [PATCH 22/24] Update org.springframework.boot.version to v3.4.1 --- prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 0080d16..7ba3e78 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -28,7 +28,7 @@ software.xdev.Application - 3.4.0 + 3.4.1 From 8f439729d876348b03c94e71db84f172224ac047 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Jan 2025 08:36:01 +0000 Subject: [PATCH 23/24] Release 3.0.0 --- pom.xml | 2 +- .../pom.xml | 4 ++-- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e3eac09..6d49cdb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 3.0.0-SNAPSHOT + 3.0.0 pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 7ba3e78..4e1ef12 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 3.0.0-SNAPSHOT + 3.0.0 prometheus-metrics-exposition-formats-no-protobuf-demo - 3.0.0-SNAPSHOT + 3.0.0 jar diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 1143fba..92bdb99 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 3.0.0-SNAPSHOT + 3.0.0 jar prometheus-metrics-exposition-formats-no-protobuf From 2bc0dbf7b4559f9b3d55d15bc0e985131e0d7b66 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Jan 2025 08:38:49 +0000 Subject: [PATCH 24/24] Preparing for next development iteration --- pom.xml | 2 +- .../pom.xml | 4 ++-- prometheus-metrics-exposition-formats-no-protobuf/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 6d49cdb..76fc7e2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 3.0.0 + 3.0.1-SNAPSHOT pom diff --git a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml index 4e1ef12..0efc25c 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf-root - 3.0.0 + 3.0.1-SNAPSHOT prometheus-metrics-exposition-formats-no-protobuf-demo - 3.0.0 + 3.0.1-SNAPSHOT jar diff --git a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml index 92bdb99..f66627b 100644 --- a/prometheus-metrics-exposition-formats-no-protobuf/pom.xml +++ b/prometheus-metrics-exposition-formats-no-protobuf/pom.xml @@ -6,7 +6,7 @@ software.xdev prometheus-metrics-exposition-formats-no-protobuf - 3.0.0 + 3.0.1-SNAPSHOT jar prometheus-metrics-exposition-formats-no-protobuf