diff --git a/.codespellrc b/.codespellrc index e4dbb3a7f..a1634fb0c 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,6 @@ [codespell] -# Ignore words that are valid technical terms: -# - vertx: Vert.x reactive framework -# - errorprone: Error Prone static analysis tool -ignore-words-list = vertx,errorprone +# nd: legitimate variable name in quantile algorithms +# atmost: AssertJ atMost() matcher +# re-use: hyphenated form used in comments +# errorprone: Google ErrorProne tool name +ignore-words-list = nd,atmost,re-use,errorprone diff --git a/.editorconfig b/.editorconfig index 45c1c5b5c..98cf13e2f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ indent_size = 2 [{version-rules.xml,maven-wrapper.properties,checkstyle.xml,docker-compose.yaml,docker-compose.yml,Dockerfile,example_target_info.json,mise.toml,mvnm,mvnw.cmd,generate-protobuf.sh,.gitleaksignore,prometheus.properties}] max_line_length = 200 -[{grafana-dashboard-*.json,.editorconfig,super-linter.env,lychee.toml,renovate.json5}] +[{grafana-dashboard-*.json,.editorconfig,super-linter.env,lychee.toml,renovate.json5,CODE_OF_CONDUCT.md}] max_line_length = 300 [pom.xml] @@ -18,5 +18,5 @@ max_line_length = 210 indent_size = 4 max_line_length = 120 -[{.mise/tasks/build-release.sh,.github/workflows/multi-version-test.yml}] -max_line_length = 200 +[{.mise/tasks/build-release.sh,.github/workflows/*.yml}] +max_line_length = 300 diff --git a/.github/config/.editorconfig-checker.json b/.github/config/.editorconfig-checker.json new file mode 100644 index 000000000..dcca7e17c --- /dev/null +++ b/.github/config/.editorconfig-checker.json @@ -0,0 +1,3 @@ +{ + "Exclude": [".*\\.java$"] +} diff --git a/.github/config/flint.toml b/.github/config/flint.toml new file mode 100644 index 000000000..6803f2cf2 --- /dev/null +++ b/.github/config/flint.toml @@ -0,0 +1,10 @@ +[settings] +exclude = [ + "**/src/main/generated/**", + "docs/themes/**", + "mvnw", + "simpleclient-archive/**", +] + +[checks.renovate-deps] +exclude_managers = ["github-actions", "github-runners"] diff --git a/.github/renovate-tracked-deps.json b/.github/renovate-tracked-deps.json index d378b8b0f..39e98fcf1 100644 --- a/.github/renovate-tracked-deps.json +++ b/.github/renovate-tracked-deps.json @@ -1,42 +1,68 @@ { ".github/renovate.json5": { - "renovate-config-presets": ["grafana/flint"] + "renovate-config-presets": [ + "grafana/flint" + ] }, ".github/workflows/acceptance-tests.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/build.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/generate-protobuf.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/github-pages.yaml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/java-version-matrix-tests.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/lint.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/native-tests.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/nightly-benchmarks.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/release.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".github/workflows/test-release-build.yml": { - "regex": ["mise"] + "regex": [ + "mise" + ] }, ".mise/envs/native/mise.toml": { - "mise": ["java"] + "mise": [ + "java" + ] }, ".mvn/wrapper/maven-wrapper.properties": { - "maven-wrapper": ["maven"] + "maven-wrapper": [ + "maven" + ] }, "benchmarks/pom.xml": { "maven": [ @@ -94,13 +120,21 @@ ] }, "integration-tests/it-exporter/it-exporter-test/pom.xml": { - "maven": ["io.prometheus:it-common", "io.prometheus:it-exporter"] + "maven": [ + "io.prometheus:it-common", + "io.prometheus:it-exporter" + ] }, "integration-tests/it-exporter/it-no-protobuf-test/pom.xml": { - "maven": ["io.prometheus:it-common", "io.prometheus:it-exporter"] + "maven": [ + "io.prometheus:it-common", + "io.prometheus:it-exporter" + ] }, "integration-tests/it-exporter/pom.xml": { - "maven": ["io.prometheus:integration-tests"] + "maven": [ + "io.prometheus:integration-tests" + ] }, "integration-tests/it-pushgateway/pom.xml": { "maven": [ @@ -114,7 +148,6 @@ }, "integration-tests/it-spring-boot-smoke-test/pom.xml": { "maven": [ - "com.diffplug.spotless:spotless-maven-plugin", "io.prometheus:it-common", "io.prometheus:prometheus-metrics-bom", "org.junit:junit-bom", @@ -130,22 +163,35 @@ }, "mise.toml": { "mise": [ + "actionlint", + "cargo:https://github.com/grafana/flint", + "cargo:xmloxide", + "editorconfig-checker", + "github:google/google-java-format", "go:github.com/gohugoio/hugo", "go:github.com/grafana/oats", "java", "lychee", "node", + "npm:markdownlint-cli2", + "npm:prettier", "npm:renovate", + "pipx:codespell", + "pipx:ruff", "protoc", - "ubi:google/google-java-format" - ], - "regex": ["ghcr.io/super-linter/super-linter", "grafana/flint"] + "shellcheck", + "shfmt" + ] }, "mvnw": { - "maven-wrapper": ["maven-wrapper"] + "maven-wrapper": [ + "maven-wrapper" + ] }, "mvnw.cmd": { - "maven-wrapper": ["maven-wrapper"] + "maven-wrapper": [ + "maven-wrapper" + ] }, "pom.xml": { "maven": [ @@ -219,7 +265,9 @@ ] }, "prometheus-metrics-config/pom.xml": { - "maven": ["io.prometheus:client_java"] + "maven": [ + "io.prometheus:client_java" + ] }, "prometheus-metrics-core/pom.xml": { "maven": [ @@ -241,7 +289,10 @@ ] }, "prometheus-metrics-exporter-httpserver/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:prometheus-metrics-exporter-common"] + "maven": [ + "io.prometheus:client_java", + "io.prometheus:prometheus-metrics-exporter-common" + ] }, "prometheus-metrics-exporter-opentelemetry-otel-agent-resources/pom.xml": { "maven": [ @@ -350,14 +401,18 @@ ] }, "prometheus-metrics-model/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:prometheus-metrics-config"] + "maven": [ + "io.prometheus:client_java", + "io.prometheus:prometheus-metrics-config" + ] }, "prometheus-metrics-otel-support/pom.xml": { - "maven": ["io.prometheus:client_java"] + "maven": [ + "io.prometheus:client_java" + ] }, "prometheus-metrics-parent/pom.xml": { "maven": [ - "com.diffplug.spotless:spotless-maven-plugin", "org.apache.maven.plugins:maven-gpg-plugin", "org.apache.maven.plugins:maven-source-plugin", "org.sonatype.central:central-publishing-maven-plugin" @@ -374,10 +429,14 @@ ] }, "prometheus-metrics-tracer/pom.xml": { - "maven": ["io.prometheus:client_java"] + "maven": [ + "io.prometheus:client_java" + ] }, "prometheus-metrics-tracer/prometheus-metrics-tracer-common/pom.xml": { - "maven": ["io.prometheus:prometheus-metrics-tracer"] + "maven": [ + "io.prometheus:prometheus-metrics-tracer" + ] }, "prometheus-metrics-tracer/prometheus-metrics-tracer-initializer/pom.xml": { "maven": [ @@ -400,7 +459,9 @@ ] }, "simpleclient-archive/integration_tests/it_common/pom.xml": { - "maven": ["io.prometheus:integration_tests"] + "maven": [ + "io.prometheus:integration_tests" + ] }, "simpleclient-archive/integration_tests/it_exemplars_otel_agent/pom.xml": { "maven": [ @@ -475,7 +536,10 @@ ] }, "simpleclient-archive/simpleclient_graphite_bridge/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:simpleclient"] + "maven": [ + "io.prometheus:client_java", + "io.prometheus:simpleclient" + ] }, "simpleclient-archive/simpleclient_hibernate/pom.xml": { "maven": [ diff --git a/.github/workflows/java-version-matrix-tests.yml b/.github/workflows/java-version-matrix-tests.yml index 1d58513cc..b9b4ecc05 100644 --- a/.github/workflows/java-version-matrix-tests.yml +++ b/.github/workflows/java-version-matrix-tests.yml @@ -4,11 +4,11 @@ name: Integration Tests - Java Version Compatibility Matrix on: pull_request: paths: - - 'integration-tests/**' - - 'prometheus-metrics-core/**' - - 'prometheus-metrics-exporter-*/**' - - 'prometheus-metrics-exposition-*/**' - - '.github/workflows/java-version-matrix-tests.yml' + - "integration-tests/**" + - "prometheus-metrics-core/**" + - "prometheus-metrics-exporter-*/**" + - "prometheus-metrics-exposition-*/**" + - ".github/workflows/java-version-matrix-tests.yml" push: branches: - main @@ -23,7 +23,6 @@ jobs: strategy: fail-fast: false matrix: - # Note: Java 8 runtime testing is skipped due to Spotless incompatibility java-version: [11, 17, 21, 25] steps: - name: Check out @@ -46,15 +45,14 @@ jobs: ${{ runner.os }}-maven- - name: Build core library artifacts - run: mise exec -- ./mvnw install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn -pl '!integration-tests' + run: mise exec -- ./mvnw install -DskipTests -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn -pl '!integration-tests' - name: Install parent POMs run: | cd integration-tests - mise exec -- ../mvnw clean install -N -Dspotless.skip=true + mise exec -- ../mvnw clean install -N cd it-exporter - mise exec -- ../../mvnw install -N -Dspotless.skip=true - + mise exec -- ../../mvnw install -N - name: Rebuild sample apps targeting Java ${{ matrix.java-version }} run: | cd integration-tests @@ -64,7 +62,7 @@ jobs: else MODULES="it-common,it-exporter/it-exporter-httpserver-sample,it-exporter/it-exporter-servlet-tomcat-sample,it-exporter/it-exporter-servlet-jetty-sample,it-exporter/it-exporter-no-protobuf,it-pushgateway" fi - mise exec -- ../mvnw clean install -DskipTests -Dspotless.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \ + mise exec -- ../mvnw clean install -DskipTests -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \ -Djava.version=${{ matrix.java-version }} \ -Dmaven.compiler.release=${{ matrix.java-version }} \ -pl $MODULES @@ -80,5 +78,5 @@ jobs: else TEST_MODULES="it-exporter/it-exporter-test,it-exporter/it-no-protobuf-test,it-pushgateway" fi - mise exec -- ../mvnw verify -T 2C -Dspotless.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \ + mise exec -- ../mvnw verify -T 2C -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn \ -pl $TEST_MODULES diff --git a/.github/workflows/multi-version-test.yml b/.github/workflows/multi-version-test.yml index 92318c1aa..6bf72fc15 100644 --- a/.github/workflows/multi-version-test.yml +++ b/.github/workflows/multi-version-test.yml @@ -36,4 +36,4 @@ jobs: ${{ runner.os }}-maven- - name: Build and test on Java ${{ matrix.java }} - run: ./mvnw clean install -Dtest.java.version=${{ matrix.java }} -Dspotless.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn -Dcoverage.skip=true + run: ./mvnw clean install -Dtest.java.version=${{ matrix.java }} -Dcheckstyle.skip=true -Dwarnings=-nowarn -Dcoverage.skip=true diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc new file mode 100644 index 000000000..cfc8400be --- /dev/null +++ b/.markdownlint.jsonc @@ -0,0 +1,6 @@ +{ + // Line length — pre-existing across docs, README, benchmarks + "MD013": false, + // Inline HTML — needed for badge images in README + "MD033": false +} diff --git a/.mise/tasks/lint/example-poms.py b/.mise/tasks/lint/example-poms.py index f9b5b776b..9a7bf0479 100755 --- a/.mise/tasks/lint/example-poms.py +++ b/.mise/tasks/lint/example-poms.py @@ -6,11 +6,12 @@ Example modules are intentionally standalone (no from the project) so users can copy them. But they're included in the Maven reactor via the -examples-and-integration-tests profile. If 'mise run format' doesn't -exclude them, spotless:apply fails because the plugin isn't declared. +examples-and-integration-tests profile. If 'mise run format' uses spotless +and doesn't exclude them, spotless:apply fails because the plugin isn't +declared in standalone example POMs. -This lint verifies that every standalone example POM is excluded from -the format task in mise.toml. +This lint verifies that when a spotless-based format task exists, it +excludes the examples-and-integration-tests profile. """ import re @@ -41,16 +42,20 @@ def find_standalone_example_poms() -> list[Path]: return standalone -def format_task_excludes_examples() -> bool: - """Check that the format task in mise.toml excludes standalone examples.""" +def spotless_format_task_excludes_examples() -> bool: + """Check that the spotless-based format task (if any) excludes standalone examples.""" mise_toml = ROOT / "mise.toml" text = mise_toml.read_text(encoding="utf-8") # Look for the format task run command match = re.search(r'\[tasks\.format\].*?run\s*=\s*"([^"]*)"', text, re.DOTALL) if not match: - return False + # No format task — nothing to check + return True run_cmd = match.group(1) - # The command should deactivate the examples-and-integration-tests profile + # If the format task doesn't use spotless, standalone examples can't break it + if "spotless" not in run_cmd: + return True + # The spotless command should deactivate the examples-and-integration-tests profile return "!examples-and-integration-tests" in run_cmd @@ -59,7 +64,7 @@ def main() -> int: if not standalone: return 0 - if format_task_excludes_examples(): + if spotless_format_task_excludes_examples(): return 0 print("ERROR: Standalone example POMs found but 'mise run format'") diff --git a/CHANGELOG.md b/CHANGELOG.md index 994794330..af5c0f91d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,22 @@ ## [1.5.1](https://github.com/prometheus/client_java/compare/v1.5.0...v1.5.1) (2026-03-20) - ### Bug Fixes -* **deps:** update dependency io.prometheus:prometheus-metrics-bom to v1.5.0 ([#1877](https://github.com/prometheus/client_java/issues/1877)) ([043fc57](https://github.com/prometheus/client_java/commit/043fc5742752fdc2f67f0219418030a190c53bde)) -* **deps:** update dependency org.springframework.boot:spring-boot-starter-parent to v4.0.3 ([#1900](https://github.com/prometheus/client_java/issues/1900)) ([0d800d0](https://github.com/prometheus/client_java/commit/0d800d0a91578e48f34909472c183174fdf1d83e)) -* **deps:** update jetty monorepo to v12.1.7 ([#1932](https://github.com/prometheus/client_java/issues/1932)) ([5bd3b79](https://github.com/prometheus/client_java/commit/5bd3b7932f454f3ed2cf55f26d6e1e1908d9ad16)) -* **deps:** update junit-framework monorepo to v6.0.3 ([#1880](https://github.com/prometheus/client_java/issues/1880)) ([05ad751](https://github.com/prometheus/client_java/commit/05ad751a40053f11eae90b9e6cbd741814ca71a7)) -* exclude standalone examples from `mise run format` ([#1931](https://github.com/prometheus/client_java/issues/1931)) ([537fb88](https://github.com/prometheus/client_java/commit/537fb88aae4048ab36041268f902afbbdce54a96)) -* fix release-please PR title pattern and permissions ([#1978](https://github.com/prometheus/client_java/issues/1978)) ([d737978](https://github.com/prometheus/client_java/commit/d7379780f1351a1521c8d93d0544bffce49d02a6)) -* Handle empty datapoints in otel exporter ([#1898](https://github.com/prometheus/client_java/issues/1898)) ([59c8552](https://github.com/prometheus/client_java/commit/59c8552f3d67c06d82344383b45e07fea8ed88b9)) -* inline set-version logic in build-release.sh ([#1884](https://github.com/prometheus/client_java/issues/1884)) ([c050435](https://github.com/prometheus/client_java/commit/c050435a4153046c72d158991c4c8e064dfb24ec)) -* reduce lychee retries to avoid compounding GitHub 429s ([#1940](https://github.com/prometheus/client_java/issues/1940)) ([cc17d6e](https://github.com/prometheus/client_java/commit/cc17d6e4346c9d51e054010fddc75cf8935cbc7d)) -* remove version manipulation from build-release.sh ([#1886](https://github.com/prometheus/client_java/issues/1886)) ([93e2b6d](https://github.com/prometheus/client_java/commit/93e2b6da48abc03ba7d96ffff5020ab73c1ee8c1)) -* trigger Maven deploy on release-please published events ([#1966](https://github.com/prometheus/client_java/issues/1966)) ([643d0e7](https://github.com/prometheus/client_java/commit/643d0e70c274e2a55024611c73a53545a65e94a0)) -* use /tree/ instead of /blob/ for directory URL ([#1944](https://github.com/prometheus/client_java/issues/1944)) ([b81332e](https://github.com/prometheus/client_java/commit/b81332e3a09e465f956f118a2403e64b83771ae5)) -* use maven release type for release-please ([#1967](https://github.com/prometheus/client_java/issues/1967)) ([ff3bd2d](https://github.com/prometheus/client_java/commit/ff3bd2d329acdb6761044846559c353a526c0384)) - +- **deps:** update dependency io.prometheus:prometheus-metrics-bom to v1.5.0 ([#1877](https://github.com/prometheus/client_java/issues/1877)) ([043fc57](https://github.com/prometheus/client_java/commit/043fc5742752fdc2f67f0219418030a190c53bde)) +- **deps:** update dependency org.springframework.boot:spring-boot-starter-parent to v4.0.3 ([#1900](https://github.com/prometheus/client_java/issues/1900)) ([0d800d0](https://github.com/prometheus/client_java/commit/0d800d0a91578e48f34909472c183174fdf1d83e)) +- **deps:** update jetty monorepo to v12.1.7 ([#1932](https://github.com/prometheus/client_java/issues/1932)) ([5bd3b79](https://github.com/prometheus/client_java/commit/5bd3b7932f454f3ed2cf55f26d6e1e1908d9ad16)) +- **deps:** update junit-framework monorepo to v6.0.3 ([#1880](https://github.com/prometheus/client_java/issues/1880)) ([05ad751](https://github.com/prometheus/client_java/commit/05ad751a40053f11eae90b9e6cbd741814ca71a7)) +- exclude standalone examples from `mise run format` ([#1931](https://github.com/prometheus/client_java/issues/1931)) ([537fb88](https://github.com/prometheus/client_java/commit/537fb88aae4048ab36041268f902afbbdce54a96)) +- fix release-please PR title pattern and permissions ([#1978](https://github.com/prometheus/client_java/issues/1978)) ([d737978](https://github.com/prometheus/client_java/commit/d7379780f1351a1521c8d93d0544bffce49d02a6)) +- Handle empty datapoints in otel exporter ([#1898](https://github.com/prometheus/client_java/issues/1898)) ([59c8552](https://github.com/prometheus/client_java/commit/59c8552f3d67c06d82344383b45e07fea8ed88b9)) +- inline set-version logic in build-release.sh ([#1884](https://github.com/prometheus/client_java/issues/1884)) ([c050435](https://github.com/prometheus/client_java/commit/c050435a4153046c72d158991c4c8e064dfb24ec)) +- reduce lychee retries to avoid compounding GitHub 429s ([#1940](https://github.com/prometheus/client_java/issues/1940)) ([cc17d6e](https://github.com/prometheus/client_java/commit/cc17d6e4346c9d51e054010fddc75cf8935cbc7d)) +- remove version manipulation from build-release.sh ([#1886](https://github.com/prometheus/client_java/issues/1886)) ([93e2b6d](https://github.com/prometheus/client_java/commit/93e2b6da48abc03ba7d96ffff5020ab73c1ee8c1)) +- trigger Maven deploy on release-please published events ([#1966](https://github.com/prometheus/client_java/issues/1966)) ([643d0e7](https://github.com/prometheus/client_java/commit/643d0e70c274e2a55024611c73a53545a65e94a0)) +- use /tree/ instead of /blob/ for directory URL ([#1944](https://github.com/prometheus/client_java/issues/1944)) ([b81332e](https://github.com/prometheus/client_java/commit/b81332e3a09e465f956f118a2403e64b83771ae5)) +- use maven release type for release-please ([#1967](https://github.com/prometheus/client_java/issues/1967)) ([ff3bd2d](https://github.com/prometheus/client_java/commit/ff3bd2d329acdb6761044846559c353a526c0384)) ### Documentation -* document DCO sign-off requirement for contributions ([#1937](https://github.com/prometheus/client_java/issues/1937)) ([0860e77](https://github.com/prometheus/client_java/commit/0860e7742b08ab019d129ea24c348191c3f9e0da)) +- document DCO sign-off requirement for contributions ([#1937](https://github.com/prometheus/client_java/issues/1937)) ([0860e77](https://github.com/prometheus/client_java/commit/0860e7742b08ab019d129ea24c348191c3f9e0da)) diff --git a/docs/content/_index.md b/docs/content/_index.md index 28e5165cd..23799cbde 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -13,6 +13,8 @@ The main new features of the 1.0.0 release are: - **Runtime configuration:** Configure metrics, exporters, and more at runtime using a properties file or system properties. + + **Documentation and Examples** In addition to this documentation page we created an @@ -39,6 +41,8 @@ or watch the recording on YouTube. **For users of the 0.16.0 version and older** + + Updating to the 1.0.0 version is a breaking change. However, there's a `prometheus-metrics-simpleclient-bridge` module available that allows you to use your existing simpleclient 0.16.0 metrics with the new 1.0.0 `PrometheusRegistry`. diff --git a/docs/content/config/config.md b/docs/content/config/config.md index cd7f7af7b..c78cf9d60 100644 --- a/docs/content/config/config.md +++ b/docs/content/config/config.md @@ -92,8 +92,12 @@ When the same property is defined in multiple sources, the following precedence + + **Notes** + + (1) _withExemplars()_ and _withoutExemplars()_ are available for all metric types, not just for counters
(2) Boolean value. Format: `property=true` or `property=false`.
diff --git a/docs/content/getting-started/metric-types.md b/docs/content/getting-started/metric-types.md index 97424ef5c..f1c2a2321 100644 --- a/docs/content/getting-started/metric-types.md +++ b/docs/content/getting-started/metric-types.md @@ -127,6 +127,8 @@ The default bucket boundaries are designed for measuring request durations in se use cases, you may want to define custom bucket boundaries. The histogram builder provides three methods for this: + + **1. Arbitrary Custom Boundaries** Use `classicUpperBounds(...)` to specify arbitrary bucket boundaries: @@ -153,6 +155,8 @@ Histogram queueSize = Histogram.builder() **3. Exponential Boundaries** + + Use `classicExponentialUpperBounds(start, factor, count)` for exponential growth: ```java diff --git a/examples/example-exporter-servlet-tomcat/README.md b/examples/example-exporter-servlet-tomcat/README.md index 01e76832d..5a77001f9 100644 --- a/examples/example-exporter-servlet-tomcat/README.md +++ b/examples/example-exporter-servlet-tomcat/README.md @@ -66,12 +66,15 @@ browser: from [https://github.com/prometheus/prometheus/releases](https://github.com/prometheus/prometheus/releases). 2. Extract the archive 3. Edit `prometheus.yml` and append the following snippet at the end: + ```yaml job_name: "tomcat-servlet-example" static_configs: - targets: ["localhost:8080"] ``` + 4. Run with native histograms and exemplars enabled: + ```shell ./prometheus --enable-feature=native-histograms --enable-feature=exemplar-storage ``` diff --git a/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/DuplicateMetricsIT.java b/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/DuplicateMetricsIT.java index abba6ea95..d69a65a29 100644 --- a/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/DuplicateMetricsIT.java +++ b/integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/DuplicateMetricsIT.java @@ -25,23 +25,23 @@ void testDuplicateMetricsInPrometheusTextFormat() throws IOException { String expected = """ - # HELP active_connections Active connections - # TYPE active_connections gauge - active_connections{pool="primary",type="read"} 30.0 - active_connections{pool="replica",type="write"} 10.0 - active_connections{protocol="http",region="us-east"} 42.0 - active_connections{protocol="http",region="us-west"} 38.0 - active_connections{protocol="https",region="eu-west"} 55.0 - # HELP http_requests_total Total HTTP requests by status - # TYPE http_requests_total counter - http_requests_total{endpoint="/api",status="error"} 5.0 - http_requests_total{endpoint="/health",status="error"} 2.0 - http_requests_total{method="GET",status="success"} 150.0 - http_requests_total{method="POST",status="success"} 45.0 - # HELP unique_metric_bytes_total A unique metric for reference - # TYPE unique_metric_bytes_total counter - unique_metric_bytes_total 1024.0 - """; + # HELP active_connections Active connections + # TYPE active_connections gauge + active_connections{pool="primary",type="read"} 30.0 + active_connections{pool="replica",type="write"} 10.0 + active_connections{protocol="http",region="us-east"} 42.0 + active_connections{protocol="http",region="us-west"} 38.0 + active_connections{protocol="https",region="eu-west"} 55.0 + # HELP http_requests_total Total HTTP requests by status + # TYPE http_requests_total counter + http_requests_total{endpoint="/api",status="error"} 5.0 + http_requests_total{endpoint="/health",status="error"} 2.0 + http_requests_total{method="GET",status="success"} 150.0 + http_requests_total{method="POST",status="success"} 45.0 + # HELP unique_metric_bytes_total A unique metric for reference + # TYPE unique_metric_bytes_total counter + unique_metric_bytes_total 1024.0 + """; assertThat(response.stringBody()).isEqualTo(expected); } @@ -59,25 +59,25 @@ void testDuplicateMetricsInOpenMetricsTextFormat() throws IOException { // OpenMetrics format should have UNIT for unique_metric_bytes (base name without _total) String expected = """ - # TYPE active_connections gauge - # HELP active_connections Active connections - active_connections{pool="primary",type="read"} 30.0 - active_connections{pool="replica",type="write"} 10.0 - active_connections{protocol="http",region="us-east"} 42.0 - active_connections{protocol="http",region="us-west"} 38.0 - active_connections{protocol="https",region="eu-west"} 55.0 - # TYPE http_requests counter - # HELP http_requests Total HTTP requests by status - http_requests_total{endpoint="/api",status="error"} 5.0 - http_requests_total{endpoint="/health",status="error"} 2.0 - http_requests_total{method="GET",status="success"} 150.0 - http_requests_total{method="POST",status="success"} 45.0 - # TYPE unique_metric_bytes counter - # UNIT unique_metric_bytes bytes - # HELP unique_metric_bytes A unique metric for reference - unique_metric_bytes_total 1024.0 - # EOF - """; + # TYPE active_connections gauge + # HELP active_connections Active connections + active_connections{pool="primary",type="read"} 30.0 + active_connections{pool="replica",type="write"} 10.0 + active_connections{protocol="http",region="us-east"} 42.0 + active_connections{protocol="http",region="us-west"} 38.0 + active_connections{protocol="https",region="eu-west"} 55.0 + # TYPE http_requests counter + # HELP http_requests Total HTTP requests by status + http_requests_total{endpoint="/api",status="error"} 5.0 + http_requests_total{endpoint="/health",status="error"} 2.0 + http_requests_total{method="GET",status="success"} 150.0 + http_requests_total{method="POST",status="success"} 45.0 + # TYPE unique_metric_bytes counter + # UNIT unique_metric_bytes bytes + # HELP unique_metric_bytes A unique metric for reference + unique_metric_bytes_total 1024.0 + # EOF + """; assertThat(response.stringBody()).isEqualTo(expected); } diff --git a/integration-tests/it-spring-boot-smoke-test/pom.xml b/integration-tests/it-spring-boot-smoke-test/pom.xml index 480fe76c9..00f65e342 100644 --- a/integration-tests/it-spring-boot-smoke-test/pom.xml +++ b/integration-tests/it-spring-boot-smoke-test/pom.xml @@ -168,24 +168,6 @@ - - com.diffplug.spotless - spotless-maven-plugin - 3.3.0 - - - - - - - - verify - - check - - - - diff --git a/mise.toml b/mise.toml index 7c1906ab5..c4beeeb4c 100644 --- a/mise.toml +++ b/mise.toml @@ -1,17 +1,25 @@ [tools] +"cargo:https://github.com/grafana/flint" = "branch:feat/flint-v2" "go:github.com/gohugoio/hugo" = "v0.157.0" "go:github.com/grafana/oats" = "0.6.1" +"cargo:xmloxide" = "0.4.1" +"github:google/google-java-format" = "1.26.0" +actionlint = "1.7.10" +editorconfig-checker = "v3.6.1" java = "temurin-25.0.2+10.0.LTS" lychee = "0.23.0" node = "24.14.0" +"npm:markdownlint-cli2" = "0.17.2" +"npm:prettier" = "3.8.1" "npm:renovate" = "43.45.1" +"pipx:codespell" = "2.4.1" +"pipx:ruff" = "0.15.0" protoc = "34.0" -"ubi:google/google-java-format" = "1.34.1" +shellcheck = "v0.11.0" +shfmt = "v3.12.0" [env] -RENOVATE_TRACKED_DEPS_EXCLUDE="github-actions,github-runners" -# renovate: datasource=docker depName=ghcr.io/super-linter/super-linter -SUPER_LINTER_VERSION="slim-v8.5.0@sha256:857dcc3f0bf5dd065fdeed1ace63394bb2004238a5ef02910ea23d9bcd8fd2b8" +FLINT_CONFIG_DIR = ".github/config" [tasks.ci] description = "CI Build" @@ -19,28 +27,22 @@ run = "./mvnw clean install" env.REQUIRE_PROTO_UP_TO_DATE = "true" env.PROTO_GENERATION = "true" -[tasks.format] -description = "format source code" -# Use fully-qualified plugin goal and deactivate the examples-and-integration-tests -# profile because standalone example modules don't inherit the spotless plugin. -run = "./mvnw com.diffplug.spotless:spotless-maven-plugin:apply -P '!examples-and-integration-tests'" - [tasks.clean] description = "clean all modules" run = "./mvnw clean" [tasks.compile] description = "bare compile, ignoring formatting and linters" -run = "./mvnw install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" +run = "./mvnw install -DskipTests -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" [tasks.generate] description = "regenerate protobuf sources" -run = "./mvnw clean install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" +run = "./mvnw clean install -DskipTests -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" env.PROTO_GENERATION = "true" [tasks.test] description = "run unit tests, ignoring formatting and linters" -run = "./mvnw test -Dspotless.check.skip=true -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" +run = "./mvnw test -Dcoverage.skip=true -Dcheckstyle.skip=true -Dwarnings=-nowarn" [tasks.test-all] description = "run all tests" @@ -50,59 +52,22 @@ run = "./mvnw verify" description = "build all modules without tests" run = "./mvnw install -DskipTests -Dcoverage.skip=true" -# Shared lint tasks from flint (https://github.com/grafana/flint) -[tasks."lint:super-linter"] -description = "Run Super-Linter on the repository" -file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/lint/super-linter.sh" # v0.9.1 - -[tasks."lint:links"] -description = "Lint links" -file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/lint/links.sh" # v0.9.1 - -[tasks."lint:renovate-deps"] -description = "Verify renovate-tracked-deps.json is up to date" -file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/lint/renovate-deps.py" # v0.9.1 - -[tasks."setup:native-lint-tools"] -description = "Install native lint tools matching the pinned super-linter version" -file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/setup/native-lint-tools.sh" # v0.9.1 - -[tasks."lint:java"] -description = "Check Java formatting (changed files only)" -run = """ -files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java') -[ -z "$files" ] && exit 0 -google-java-format --dry-run --set-exit-if-changed $files -""" - -[tasks."lint:fast"] -description = "Run fast lints (no Renovate)" -depends = ["lint:super-linter", "lint:links", "lint:bom", "lint:example-poms", "lint:java"] - [tasks."lint"] description = "Run all lints" -depends = ["lint:fast", "lint:renovate-deps"] +depends = ["lint:bom", "lint:example-poms"] +run = "flint run" -[tasks.fix] +[tasks."lint:fix"] description = "Auto-fix lint issues" -run = """ -files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java') -[ -n "$files" ] && google-java-format -i $files -AUTOFIX=true mise run lint -""" +run = "flint run --fix" -[tasks.native-lint] -description = "Run lints natively (no container)" -run = "NATIVE=true mise run lint:fast" +[tasks."lint:pre-commit"] +description = "Fast auto-fix lint pass — intended for pre-commit/pre-push hooks" +run = "flint run --fix --fast-only" -[tasks.pre-commit] -description = "Pre-commit hook: native lint" -depends = ["setup:native-lint-tools"] -run = "NATIVE=true mise run lint:fast" - -[tasks."setup:pre-commit-hook"] -description = "Install git pre-commit hook that runs native linting" -run = "mise generate git-pre-commit --write --task=pre-commit" +[tasks.fix] +description = "Auto-fix lint issues" +run = "flint run --fix" [tasks.acceptance-test] description = "Run OATs acceptance tests" diff --git a/pom.xml b/pom.xml index 229d204d4..c20dd89c6 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,6 @@ 0.70 false false - false false -Werror diff --git a/prometheus-metrics-bom/pom.xml b/prometheus-metrics-bom/pom.xml index ae0b5fbd5..535284b10 100644 --- a/prometheus-metrics-bom/pom.xml +++ b/prometheus-metrics-bom/pom.xml @@ -17,9 +17,6 @@ Bill of Materials for the Prometheus Metrics library - - true - diff --git a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java index c104e532a..89bc1699b 100644 --- a/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java +++ b/prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java @@ -122,7 +122,8 @@ void testTotalStrippedFromName(String name) { new PrometheusProtobufWriterImpl().convert(counter.collect(), EscapingScheme.ALLOW_UTF8); assertThat(ProtobufUtil.shortDebugString(protobufData)) .matches( - "^name: \"my_counter_seconds_total\" type: COUNTER metric \\{ counter \\{ value: 0.0 created_timestamp \\{ seconds: \\d+ nanos: \\d+ } } }$"); + "^name: \"my_counter_seconds_total\" type: COUNTER metric \\{ counter \\{ value: 0.0" + + " created_timestamp \\{ seconds: \\d+ nanos: \\d+ } } }$"); } @Test diff --git a/prometheus-metrics-otel-support/pom.xml b/prometheus-metrics-otel-support/pom.xml index 58c231cb1..238f15ba6 100644 --- a/prometheus-metrics-otel-support/pom.xml +++ b/prometheus-metrics-otel-support/pom.xml @@ -21,7 +21,6 @@ true true - true true diff --git a/prometheus-metrics-parent/pom.xml b/prometheus-metrics-parent/pom.xml index fa89eb1c9..b0f9d5f2c 100644 --- a/prometheus-metrics-parent/pom.xml +++ b/prometheus-metrics-parent/pom.xml @@ -16,7 +16,6 @@ true true - true true @@ -70,35 +69,6 @@ - - java17-plus - - [17,) - - - - - com.diffplug.spotless - spotless-maven-plugin - 3.3.0 - - - - - ${spotless.skip} - - - - verify - - check - - - - - - - release diff --git a/prometheus-metrics-tracer/prometheus-metrics-tracer-common/src/main/java/io/prometheus/metrics/tracer/common/SpanContext.java b/prometheus-metrics-tracer/prometheus-metrics-tracer-common/src/main/java/io/prometheus/metrics/tracer/common/SpanContext.java index 7d087f8b5..f2c171a10 100644 --- a/prometheus-metrics-tracer/prometheus-metrics-tracer-common/src/main/java/io/prometheus/metrics/tracer/common/SpanContext.java +++ b/prometheus-metrics-tracer/prometheus-metrics-tracer-common/src/main/java/io/prometheus/metrics/tracer/common/SpanContext.java @@ -25,7 +25,7 @@ public interface SpanContext { * @return the state of the current Span. If this value is false a component before in the chain * take the decision to not record it. Subsequent calling service have to respect this value * in order not to have partial TraceID with only some Span in it. This value is important to - * be sure to choose a recorded Trace in Examplar sampling process + * be sure to choose a recorded Trace in Exemplar sampling process */ boolean isCurrentSpanSampled();