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..b44b17eaf --- /dev/null +++ b/.github/config/.editorconfig-checker.json @@ -0,0 +1,4 @@ +{ + "_comment": "Java files are handled by flint, so editorconfig-checker ignores them.", + "Exclude": [".*\\.java$"] +} diff --git a/.github/config/flint.toml b/.github/config/flint.toml new file mode 100644 index 000000000..cc437ea00 --- /dev/null +++ b/.github/config/flint.toml @@ -0,0 +1,14 @@ +[settings] +# These paths are generated, vendored, or handled by other checks. +exclude = [ + "CHANGELOG.md", + "**/src/main/generated/**", + "docs/themes/**", + "mvnw", + "simpleclient-archive/**", +] + +[checks.renovate-deps] +# This inventory is regenerated from the files flint still inspects, so +# super-linter-era entries drop out when they are excluded or no longer used. +exclude_managers = ["github-actions", "github-runners", "maven"] diff --git a/.github/renovate-tracked-deps.json b/.github/renovate-tracked-deps.json index a3edc1ec8..e0d8185f9 100644 --- a/.github/renovate-tracked-deps.json +++ b/.github/renovate-tracked-deps.json @@ -1,591 +1,100 @@ { ".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"] - }, - ".github/workflows/github-pages.yaml": { - "regex": ["mise"] - }, - ".github/workflows/java-version-matrix-tests.yml": { - "regex": ["mise"] - }, - ".github/workflows/lint.yml": { - "regex": ["mise"] - }, - ".github/workflows/native-tests.yml": { - "regex": ["mise"] - }, - ".github/workflows/nightly-benchmarks.yml": { - "regex": ["mise"] - }, - ".github/workflows/release.yml": { - "regex": ["mise"] - }, - ".github/workflows/test-release-build.yml": { - "regex": ["mise"] - }, - ".mise/envs/native/mise.toml": { - "mise": ["java"] - }, - ".mvn/wrapper/maven-wrapper.properties": { - "maven-wrapper": ["maven"] - }, - "benchmarks/pom.xml": { - "maven": [ - "com.codahale.metrics:metrics-core", - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exposition-textformats", - "io.prometheus:simpleclient", - "org.openjdk.jmh:jmh-core", - "org.openjdk.jmh:jmh-generator-annprocess" + "regex": [ + "mise" ] }, - "integration-tests/it-common/pom.xml": { - "maven": [ - "io.prometheus:integration-tests", - "io.prometheus:prometheus-metrics-exposition-formats" + ".github/workflows/github-pages.yaml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-duplicate-metrics-sample/pom.xml": { - "maven": [ - "io.prometheus:it-exporter", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver" + ".github/workflows/java-version-matrix-tests.yml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-httpserver-sample/pom.xml": { - "maven": [ - "io.prometheus:it-exporter", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver" + ".github/workflows/lint.yml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-no-protobuf/pom.xml": { - "maven": [ - "io.prometheus:it-exporter", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver" + ".github/workflows/native-tests.yml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-servlet-jetty-sample/pom.xml": { - "maven": [ - "io.prometheus:it-exporter", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-servlet-jakarta", - "org.eclipse.jetty.ee10:jetty-ee10-servlet", - "org.eclipse.jetty:jetty-server" + ".github/workflows/nightly-benchmarks.yml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-servlet-tomcat-sample/pom.xml": { - "maven": [ - "io.prometheus:it-exporter", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-servlet-jakarta", - "org.apache.tomcat.embed:tomcat-embed-core" + ".github/workflows/release.yml": { + "regex": [ + "mise" ] }, - "integration-tests/it-exporter/it-exporter-test/pom.xml": { - "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"] - }, - "integration-tests/it-exporter/pom.xml": { - "maven": ["io.prometheus:integration-tests"] - }, - "integration-tests/it-pushgateway/pom.xml": { - "maven": [ - "com.jayway.jsonpath:json-path", - "com.squareup.okhttp:okhttp", - "io.prometheus:integration-tests", - "io.prometheus:it-common", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-pushgateway" + ".github/workflows/test-release-build.yml": { + "regex": [ + "mise" ] }, - "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", - "org.springframework.boot:spring-boot-starter-parent" + ".mise/envs/native/mise.toml": { + "mise": [ + "java" ] }, - "integration-tests/pom.xml": { - "maven": [ - "commons-io:commons-io", - "io.prometheus:client_java", - "org.testcontainers:junit-jupiter" + ".mvn/wrapper/maven-wrapper.properties": { + "maven-wrapper": [ + "maven" ] }, "mise.toml": { "mise": [ + "actionlint", + "cargo:xmloxide", + "editorconfig-checker", + "github:google/google-java-format", + "github:grafana/flint", "go:github.com/gohugoio/hugo", "go:github.com/grafana/oats", "java", "lychee", "node", + "npm:@biomejs/biome", + "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/docker-otel-lgtm", "grafana/flint"] - }, - "mvnw": { - "maven-wrapper": ["maven-wrapper"] - }, - "mvnw.cmd": { - "maven-wrapper": ["maven-wrapper"] - }, - "pom.xml": { - "maven": [ - "com.google.code.findbugs:jsr305", - "com.google.errorprone:error_prone_core", - "com.google.guava:guava", - "com.google.protobuf:protobuf-java", - "com.uber.nullaway:nullaway", - "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha", - "io.opentelemetry:opentelemetry-proto", - "io.prometheus:client_java_parent", - "org.apache.felix:maven-bundle-plugin", - "org.apache.maven.plugins:maven-checkstyle-plugin", - "org.apache.maven.plugins:maven-clean-plugin", - "org.apache.maven.plugins:maven-compiler-plugin", - "org.apache.maven.plugins:maven-dependency-plugin", - "org.apache.maven.plugins:maven-deploy-plugin", - "org.apache.maven.plugins:maven-enforcer-plugin", - "org.apache.maven.plugins:maven-failsafe-plugin", - "org.apache.maven.plugins:maven-install-plugin", - "org.apache.maven.plugins:maven-jar-plugin", - "org.apache.maven.plugins:maven-javadoc-plugin", - "org.apache.maven.plugins:maven-resources-plugin", - "org.apache.maven.plugins:maven-shade-plugin", - "org.apache.maven.plugins:maven-site-plugin", - "org.apache.maven.plugins:maven-surefire-plugin", - "org.assertj:assertj-core", - "org.awaitility:awaitility", - "org.codehaus.mojo:build-helper-maven-plugin", - "org.codehaus.mojo:exec-maven-plugin", - "org.codehaus.mojo:versions-maven-plugin", - "org.jacoco:jacoco-maven-plugin", - "org.junit-pioneer:junit-pioneer", - "org.junit.jupiter:junit-jupiter", - "org.junit.jupiter:junit-jupiter-params", - "org.junit:junit-bom", - "org.mockito:mockito-core", - "org.slf4j:slf4j-simple", - "org.wiremock:wiremock" - ] - }, - "prometheus-metrics-bom/pom.xml": { - "maven": [ - "io.prometheus:client_java_parent", - "io.prometheus:prometheus-metrics-config", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-common", - "io.prometheus:prometheus-metrics-exporter-httpserver", - "io.prometheus:prometheus-metrics-exporter-opentelemetry", - "io.prometheus:prometheus-metrics-exporter-opentelemetry-no-otel", - "io.prometheus:prometheus-metrics-exporter-opentelemetry-otel-agent-resources", - "io.prometheus:prometheus-metrics-exporter-pushgateway", - "io.prometheus:prometheus-metrics-exporter-servlet-jakarta", - "io.prometheus:prometheus-metrics-exporter-servlet-javax", - "io.prometheus:prometheus-metrics-exposition-formats", - "io.prometheus:prometheus-metrics-exposition-formats-no-protobuf", - "io.prometheus:prometheus-metrics-exposition-textformats", - "io.prometheus:prometheus-metrics-instrumentation-caffeine", - "io.prometheus:prometheus-metrics-instrumentation-dropwizard", - "io.prometheus:prometheus-metrics-instrumentation-dropwizard5", - "io.prometheus:prometheus-metrics-instrumentation-guava", - "io.prometheus:prometheus-metrics-instrumentation-jvm", - "io.prometheus:prometheus-metrics-model", - "io.prometheus:prometheus-metrics-otel-support", - "io.prometheus:prometheus-metrics-simpleclient-bridge", - "io.prometheus:prometheus-metrics-tracer", - "io.prometheus:prometheus-metrics-tracer-common", - "io.prometheus:prometheus-metrics-tracer-initializer", - "io.prometheus:prometheus-metrics-tracer-otel", - "io.prometheus:prometheus-metrics-tracer-otel-agent" - ] - }, - "prometheus-metrics-config/pom.xml": { - "maven": ["io.prometheus:client_java"] - }, - "prometheus-metrics-core/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-config", - "io.prometheus:prometheus-metrics-exposition-formats-no-protobuf", - "io.prometheus:prometheus-metrics-model", - "io.prometheus:prometheus-metrics-tracer-initializer", - "org.apache.commons:commons-math3" - ] - }, - "prometheus-metrics-exporter-common/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exposition-formats", - "io.prometheus:prometheus-metrics-exposition-textformats", - "io.prometheus:prometheus-metrics-model" - ] - }, - "prometheus-metrics-exporter-httpserver/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:prometheus-metrics-exporter-common"] - }, - "prometheus-metrics-exporter-opentelemetry-otel-agent-resources/pom.xml": { - "maven": [ - "io.opentelemetry:opentelemetry-api", - "io.opentelemetry:opentelemetry-context", - "io.prometheus:client_java" - ] - }, - "prometheus-metrics-exporter-opentelemetry-shaded/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-opentelemetry-otel-agent-resources" - ] - }, - "prometheus-metrics-exporter-opentelemetry/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-opentelemetry-otel-agent-resources" - ] - }, - "prometheus-metrics-exporter-pushgateway/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-common", - "org.mock-server:mockserver-netty-no-dependencies" - ] - }, - "prometheus-metrics-exporter-servlet-jakarta/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-common", - "jakarta.servlet:jakarta.servlet-api" - ] - }, - "prometheus-metrics-exporter-servlet-javax/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-common", - "javax.servlet:javax.servlet-api" - ] - }, - "prometheus-metrics-exposition-formats-shaded/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-exposition-formats/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-exposition-textformats/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-config", - "io.prometheus:prometheus-metrics-model" - ] - }, - "prometheus-metrics-instrumentation-caffeine/pom.xml": { - "maven": [ - "com.github.ben-manes.caffeine:caffeine", - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-instrumentation-dropwizard/pom.xml": { - "maven": [ - "io.dropwizard.metrics:metrics-core", - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver", - "io.prometheus:prometheus-metrics-exposition-textformats", - "io.prometheus:prometheus-metrics-instrumentation-dropwizard5" - ] - }, - "prometheus-metrics-instrumentation-dropwizard5/pom.xml": { - "maven": [ - "io.dropwizard.metrics5:metrics-core", - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-instrumentation-guava/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-instrumentation-jvm/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-core", - "io.prometheus:prometheus-metrics-exporter-httpserver", - "io.prometheus:prometheus-metrics-exposition-textformats" - ] - }, - "prometheus-metrics-model/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:prometheus-metrics-config"] - }, - "prometheus-metrics-otel-support/pom.xml": { - "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" - ] - }, - "prometheus-metrics-simpleclient-bridge/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:prometheus-metrics-config", - "io.prometheus:prometheus-metrics-exposition-textformats", - "io.prometheus:prometheus-metrics-model", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common" + "shellcheck", + "shfmt" ] }, - "prometheus-metrics-tracer/pom.xml": { - "maven": ["io.prometheus:client_java"] - }, - "prometheus-metrics-tracer/prometheus-metrics-tracer-common/pom.xml": { - "maven": ["io.prometheus:prometheus-metrics-tracer"] - }, - "prometheus-metrics-tracer/prometheus-metrics-tracer-initializer/pom.xml": { - "maven": [ - "io.prometheus:prometheus-metrics-tracer", - "io.prometheus:prometheus-metrics-tracer-common", - "io.prometheus:prometheus-metrics-tracer-otel", - "io.prometheus:prometheus-metrics-tracer-otel-agent" - ] - }, - "prometheus-metrics-tracer/prometheus-metrics-tracer-otel-agent/pom.xml": { - "maven": [ - "io.prometheus:prometheus-metrics-tracer", - "io.prometheus:prometheus-metrics-tracer-common" - ] - }, - "prometheus-metrics-tracer/prometheus-metrics-tracer-otel/pom.xml": { - "maven": [ - "io.prometheus:prometheus-metrics-tracer", - "io.prometheus:prometheus-metrics-tracer-common" - ] - }, - "simpleclient-archive/integration_tests/it_common/pom.xml": { - "maven": ["io.prometheus:integration_tests"] - }, - "simpleclient-archive/integration_tests/it_exemplars_otel_agent/pom.xml": { - "maven": [ - "ch.qos.logback:logback-classic", - "io.prometheus:integration_tests", - "io.prometheus:it_common", - "io.prometheus:simpleclient_bom", - "io.prometheus:simpleclient_hotspot", - "io.prometheus:simpleclient_servlet", - "org.springframework.boot:spring-boot-dependencies", - "org.springframework.boot:spring-boot-maven-plugin" - ] - }, - "simpleclient-archive/integration_tests/it_exemplars_otel_sdk/pom.xml": { - "maven": [ - "io.opentelemetry:opentelemetry-api", - "io.opentelemetry:opentelemetry-sdk", - "io.prometheus:integration_tests", - "io.prometheus:it_common", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_httpserver" - ] - }, - "simpleclient-archive/integration_tests/it_java_versions/pom.xml": { - "maven": [ - "io.prometheus:integration_tests", - "io.prometheus:it_common", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_hotspot", - "io.prometheus:simpleclient_httpserver" - ] - }, - "simpleclient-archive/integration_tests/it_log4j2/pom.xml": { - "maven": [ - "io.prometheus:integration_tests", - "io.prometheus:it_common", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_httpserver", - "io.prometheus:simpleclient_log4j2", - "org.apache.logging.log4j:log4j-api", - "org.apache.logging.log4j:log4j-core" - ] - }, - "simpleclient-archive/integration_tests/it_pushgateway/pom.xml": { - "maven": [ - "ch.qos.logback:logback-classic", - "com.squareup.okhttp3:okhttp", - "io.prometheus:integration_tests", - "io.prometheus:it_common", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_pushgateway" - ] - }, - "simpleclient-archive/integration_tests/it_servlet_jakarta_exporter_webxml/pom.xml": { - "maven": [ - "ch.qos.logback:logback-classic", - "com.squareup.okhttp3:okhttp", - "io.prometheus:integration_tests", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_hotspot", - "io.prometheus:simpleclient_servlet_jakarta", - "jakarta.servlet:jakarta.servlet-api", - "org.apache.maven.plugins:maven-war-plugin" - ] - }, - "simpleclient-archive/integration_tests/pom.xml": { - "maven": [ - "ch.qos.logback:logback-classic", - "com.squareup.okhttp3:okhttp", - "io.prometheus:client_java", - "org.testcontainers:testcontainers" - ] - }, - "simpleclient-archive/simpleclient_graphite_bridge/pom.xml": { - "maven": ["io.prometheus:client_java", "io.prometheus:simpleclient"] - }, - "simpleclient-archive/simpleclient_hibernate/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "org.hibernate:hibernate-core" - ] - }, - "simpleclient-archive/simpleclient_httpserver/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "javax.xml.bind:jaxb-api" - ] - }, - "simpleclient-archive/simpleclient_jetty/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "org.eclipse.jetty:jetty-server", - "org.eclipse.jetty:jetty-servlet", - "org.hamcrest:hamcrest-all" - ] - }, - "simpleclient-archive/simpleclient_jetty_jdk8/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "org.eclipse.jetty:jetty-server", - "org.eclipse.jetty:jetty-servlet", - "org.hamcrest:hamcrest-all" - ] - }, - "simpleclient-archive/simpleclient_log4j/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "org.apache.logging.log4j:log4j-1.2-api", - "org.apache.logging.log4j:log4j-core" - ] - }, - "simpleclient-archive/simpleclient_log4j2/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "org.apache.logging.log4j:log4j-core" - ] - }, - "simpleclient-archive/simpleclient_logback/pom.xml": { - "maven": [ - "ch.qos.logback:logback-classic", - "io.prometheus:client_java", - "io.prometheus:simpleclient" - ] - }, - "simpleclient-archive/simpleclient_servlet/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "io.prometheus:simpleclient_servlet_common", - "javax.servlet:javax.servlet-api", - "org.eclipse.jetty:jetty-servlet" - ] - }, - "simpleclient-archive/simpleclient_servlet_common/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common" - ] - }, - "simpleclient-archive/simpleclient_servlet_jakarta/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "io.prometheus:simpleclient_servlet_common", - "jakarta.servlet:jakarta.servlet-api", - "org.eclipse.jetty:jetty-servlet" - ] - }, - "simpleclient-archive/simpleclient_spring_web/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "org.apache.commons:commons-lang3", - "org.aspectj:aspectjweaver", - "org.springframework:spring-aop", - "org.springframework:spring-context", - "org.springframework:spring-test", - "org.springframework:spring-web" - ] - }, - "simpleclient-archive/simpleclient_vertx/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "io.vertx:vertx-web" + "mvnw": { + "maven-wrapper": [ + "maven-wrapper" ] }, - "simpleclient-archive/simpleclient_vertx4/pom.xml": { - "maven": [ - "io.prometheus:client_java", - "io.prometheus:simpleclient", - "io.prometheus:simpleclient_common", - "io.vertx:vertx-web" + "mvnw.cmd": { + "maven-wrapper": [ + "maven-wrapper" ] } } diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 2b6af73f7..27afa5920 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,6 +1,6 @@ { $schema: "https://docs.renovatebot.com/renovate-schema.json", - extends: ["config:best-practices", "config:recommended", "github>grafana/flint"], + extends: ["config:best-practices", "config:recommended", "github>grafana/flint#v0.20.3"], platformCommit: "enabled", automerge: true, ignorePaths: [ diff --git a/.github/workflows/java-version-matrix-tests.yml b/.github/workflows/java-version-matrix-tests.yml index dbbd7a377..68a24b15f 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.yml b/.markdownlint.yml new file mode 100644 index 000000000..0ba730636 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,2 @@ +# Line length is enforced by editorconfig-checker via .editorconfig +MD013: false diff --git a/.mise/tasks/lint/example-poms.py b/.mise/tasks/lint/example-poms.py deleted file mode 100755 index f9b5b776b..000000000 --- a/.mise/tasks/lint/example-poms.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 - -# [MISE] description="Verify standalone example POMs won't break spotless" - -"""Check that standalone example modules don't break 'mise run format'. - -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. - -This lint verifies that every standalone example POM is excluded from -the format task in mise.toml. -""" - -import re -import sys -from pathlib import Path - -ROOT = Path(__file__).resolve().parents[3] -EXAMPLES_DIR = ROOT / "examples" - - -def find_standalone_example_poms() -> list[Path]: - """Find example pom.xml files that don't inherit from the project parent.""" - standalone = [] - for pom in sorted(EXAMPLES_DIR.rglob("pom.xml")): - if "target" in pom.parts: - continue - text = pom.read_text(encoding="utf-8") - # Check if this POM has a with the project's groupId/artifactId - has_project_parent = bool( - re.search( - r"\s*io\.prometheus\s*" - r"client_java", - text, - ) - ) - if not has_project_parent: - standalone.append(pom) - return standalone - - -def format_task_excludes_examples() -> bool: - """Check that the format task in mise.toml 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 - run_cmd = match.group(1) - # The command should deactivate the examples-and-integration-tests profile - return "!examples-and-integration-tests" in run_cmd - - -def main() -> int: - standalone = find_standalone_example_poms() - if not standalone: - return 0 - - if format_task_excludes_examples(): - return 0 - - print("ERROR: Standalone example POMs found but 'mise run format'") - print("does not exclude the examples-and-integration-tests profile.") - print() - print("Standalone example POMs (no project parent):") - for pom in standalone: - print(f" {pom.relative_to(ROOT)}") - print() - print("Fix: ensure the format task in mise.toml deactivates the") - print("examples-and-integration-tests profile, e.g.:") - print(" -P '!examples-and-integration-tests'") - return 1 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..1cbfcb82e --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +docs/themes/** diff --git a/AGENTS.md b/AGENTS.md index ba4cab7a9..9ab4664e4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,22 +21,16 @@ mise run test # Run all tests including integration tests mise run test-all -# Format code with Google Java Format -mise run format - # Run a single test class ./mvnw test -Dtest=CounterTest \ - -Dspotless.check.skip=true \ -Dcoverage.skip=true -Dcheckstyle.skip=true # Run a single test method ./mvnw test -Dtest=CounterTest#testIncrement \ - -Dspotless.check.skip=true \ -Dcoverage.skip=true -Dcheckstyle.skip=true # Run tests in a specific module ./mvnw test -pl prometheus-metrics-core \ - -Dspotless.check.skip=true \ -Dcoverage.skip=true -Dcheckstyle.skip=true # Regenerate protobuf classes (after protobuf dep update) @@ -86,7 +80,7 @@ Pre-built instrumentations: ## Code Style -- **Formatter**: Google Java Format (enforced via Spotless) +- **Formatter**: Google Java Format (enforced via flint) - **Line length**: 100 characters (enforced for ALL files including Markdown, Java, YAML) - **Indentation**: 2 spaces @@ -109,7 +103,7 @@ commits. CI will fail if these checks fail. - **ALWAYS** run `mise run build` after modifying Java files to ensure: - - Code formatting (Spotless with Google Java Format) + - Code formatting via flint - Static analysis (`Error Prone` with NullAway) - Checkstyle validation - Build succeeds (tests are skipped; @@ -119,7 +113,7 @@ commits. CI will fail if these checks fail. - **ALWAYS** run `mise run lint` after modifying non-Java files (runs super-linter + link checking + BOM check) -- `mise run fix` autofixes linting issues +- `mise run lint:fix` autofixes linting issues - Super-linter will **autofix** many issues (formatting, trailing whitespace, etc.) - It only reports ERROR-level issues @@ -139,7 +133,7 @@ mise run build # After modifying non-Java files (run BEFORE committing) mise run lint -# or to autofix: mise run fix +# or to autofix: mise run lint:fix ``` ### Before Pushing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5ec82dc10..d2a93b676 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,18 +43,15 @@ git push --force-with-lease ## Formatting -This repository uses [Google Java Format](https://github.com/google/google-java-format) to format -the code. +This repository uses flint to run formatting and lint checks. -Run `./mvnw spotless:apply` to format the code (only changed files) before committing. - -Or run all the linters: +Run all the linters: `mise run lint` To autofix linting issues: -`mise run fix` +`mise run lint:fix` ### Pre-commit Hook (Optional) @@ -79,7 +76,6 @@ mise --cd .mise/envs/native run native-test ### Avoid failures while running tests -- Use `-Dspotless.check.skip=true` to skip the formatting check during development. - Use `-Dcoverage.skip=true` to skip the coverage check during development. - Use `-Dcheckstyle.skip=true` to skip the checkstyle check during development. - Use `-Dwarnings=-nowarn` to skip the warnings during development. @@ -87,7 +83,7 @@ mise --cd .mise/envs/native run native-test Combine all with ```shell -./mvnw install -DskipTests -Dspotless.check.skip=true -Dcoverage.skip=true \ +./mvnw install -DskipTests -Dcoverage.skip=true \ -Dcheckstyle.skip=true -Dwarnings=-nowarn ``` diff --git a/README.md b/README.md index a6b611db2..aa5a0ba52 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Prometheus Java Metrics Library -[![Build](https://github.com/prometheus/client_java/actions/workflows/build.yml/badge.svg)](https://github.com/prometheus/client_java/actions/workflows/build.yml) java 8+ Apache 2.0 # editorconfig-checker-disable-line + + +[![Build](https://github.com/prometheus/client_java/actions/workflows/build.yml/badge.svg)](https://github.com/prometheus/client_java/actions/workflows/build.yml) java 8+ Apache 2.0 + + ## Documentation diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 000000000..d79695a0b --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,8 @@ +// Biome keeps the repo's JSON and JSONC files formatted consistently. +{ + // Keep JSON formatting aligned with the repo's two-space style. + "formatter": { + "indentStyle": "space", + "indentWidth": 2 + } +} 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..4161ddb15 100644 --- a/docs/content/config/config.md +++ b/docs/content/config/config.md @@ -92,7 +92,9 @@ When the same property is defined in multiple sources, the following precedence -**Notes** +### Notes + + (1) _withExemplars()_ and _withoutExemplars()_ are available for all metric types, not just for counters
@@ -102,6 +104,8 @@ not just for counters
(5) Comma-separated list. If specified, the list must have the same length as `io.prometheus.metrics.summary_quantiles`. Example: `0.01, 0.005, 0.005`. + + There's one special feature about metric properties: You can set a property for one specific metric only by specifying the metric name. Example: Let's say you have a histogram named `latency_seconds`. @@ -158,12 +162,16 @@ This works for all Metrics properties. + + (1) Comma separated list of allowed metric names. Only these metrics will be exposed.
(2) Comma separated list of excluded metric names. These metrics will not be exposed.
(3) Comma separated list of prefixes. Only metrics starting with these prefixes will be exposed.
(4) Comma separated list of prefixes. Metrics starting with these prefixes will not be exposed.
+ + ## Exporter HTTPServer Properties @@ -193,10 +201,14 @@ Only metrics starting with these prefixes will be exposed.
+ + (1) Protocol can be `grpc` or `http/protobuf`.
(2) Format: `key1=value1,key2=value2`
(3) Format: `key1=value1,key2=value2` + + Many of these attributes can alternatively be configured via OpenTelemetry environment variables, like `OTEL_EXPORTER_OTLP_ENDPOINT`. The Prometheus metrics library has support for OpenTelemetry environment variables. 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 3397051cf..79a2c170a 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 84c94d326..9b9f6a646 100644 --- a/mise.toml +++ b/mise.toml @@ -6,43 +6,47 @@ lychee = "0.23.0" node = "24.15.0" "npm:renovate" = "43.129.1" protoc = "34.0" -"ubi:google/google-java-format" = "1.34.1" + +# Linters +actionlint = "1.7.10" +"cargo:xmloxide" = "0.4.1" +editorconfig-checker = "v3.6.1" +"github:grafana/flint" = "0.20.3" +"github:google/google-java-format" = "1.26.0" +"npm:@biomejs/biome" = "2.4.12" +"npm:markdownlint-cli2" = "0.17.2" +"npm:prettier" = "3.8.1" +"pipx:codespell" = "2.4.1" +"pipx:ruff" = "0.15.0" +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" # renovate: datasource=github-releases depName=grafana/docker-otel-lgtm -LGTM_VERSION="0.25.0" +LGTM_VERSION = "0.25.0" [tasks.ci] description = "CI Build" 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" @@ -52,59 +56,15 @@ 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"] +raw_args = true +depends = ["lint:bom"] +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 -""" - -[tasks.native-lint] -description = "Run lints natively (no container)" -run = "NATIVE=true mise run lint:fast" - -[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" +run = "flint run --fix" [tasks.acceptance-test] description = "Run OATs acceptance tests" diff --git a/pom.xml b/pom.xml index 3ac47f992..12b76eb13 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..4a440b637 100644 --- a/prometheus-metrics-bom/pom.xml +++ b/prometheus-metrics-bom/pom.xml @@ -17,10 +17,6 @@ Bill of Materials for the Prometheus Metrics library - - true - - diff --git a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/ExporterPropertiesTest.java b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/ExporterPropertiesTest.java index 6cde17648..514c5ff52 100644 --- a/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/ExporterPropertiesTest.java +++ b/prometheus-metrics-config/src/test/java/io/prometheus/metrics/config/ExporterPropertiesTest.java @@ -36,8 +36,8 @@ void load() { new HashMap<>( Map.of("io.prometheus.exporter.exemplars_on_all_metric_types", "invalid")))) .withMessage( - "io.prometheus.exporter.exemplars_on_all_metric_types: Expecting 'true' or 'false'. Found:" - + " invalid"); + "io.prometheus.exporter.exemplars_on_all_metric_types: Expecting 'true' or 'false'." + + " Found: invalid"); } private static ExporterProperties load(Map map) { @@ -84,7 +84,7 @@ void prometheusTimestampsInMs() { new HashMap<>( Map.of("io.prometheus.exporter.prometheus_timestamps_in_ms", "invalid")))) .withMessage( - "io.prometheus.exporter.prometheus_timestamps_in_ms: Expecting 'true' or 'false'. Found:" - + " invalid"); + "io.prometheus.exporter.prometheus_timestamps_in_ms: Expecting 'true' or 'false'." + + " Found: invalid"); } } 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-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/DuplicateNamesExpositionTest.java b/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/DuplicateNamesExpositionTest.java index bdd21440f..d1e8c2b9a 100644 --- a/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/DuplicateNamesExpositionTest.java +++ b/prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/DuplicateNamesExpositionTest.java @@ -75,11 +75,11 @@ void testDuplicateNames_differentLabels_producesValidOutput() throws IOException String expected = """ - # HELP api_responses_total API responses - # TYPE api_responses_total counter - api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 - api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 - """; + # HELP api_responses_total API responses + # TYPE api_responses_total counter + api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 + api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 + """; assertThat(output).isEqualTo(expected); } @@ -150,13 +150,13 @@ public String getPrometheusName() { String expected = """ - # HELP api_responses_total API responses - # TYPE api_responses_total counter - api_responses_total{error="NOT_FOUND",outcome="FAILURE",uri="/world"} 5.0 - api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 - api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 - api_responses_total{outcome="SUCCESS",uri="/world"} 200.0 - """; + # HELP api_responses_total API responses + # TYPE api_responses_total counter + api_responses_total{error="NOT_FOUND",outcome="FAILURE",uri="/world"} 5.0 + api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 + api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 + api_responses_total{outcome="SUCCESS",uri="/world"} 200.0 + """; assertThat(output).isEqualTo(expected); } @@ -172,12 +172,12 @@ void testOpenMetricsFormat_withDuplicateNames() throws IOException { String expected = """ - # TYPE api_responses counter - # HELP api_responses API responses - api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 - api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 - # EOF - """; + # TYPE api_responses counter + # HELP api_responses API responses + api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 + api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 + # EOF + """; assertThat(output).isEqualTo(expected); } @@ -243,15 +243,15 @@ public String getPrometheusName() { // merged snapshots too, so single HELP/TYPE for _created and one _created line per label set. String expected = """ - # HELP api_responses_total API responses - # TYPE api_responses_total counter - api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 - api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 - # HELP api_responses_created API responses - # TYPE api_responses_created gauge - api_responses_created{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 1672850386800 - api_responses_created{outcome="SUCCESS",uri="/hello"} 1672850385800 - """; + # HELP api_responses_total API responses + # TYPE api_responses_total counter + api_responses_total{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 10.0 + api_responses_total{outcome="SUCCESS",uri="/hello"} 100.0 + # HELP api_responses_created API responses + # TYPE api_responses_created gauge + api_responses_created{error="TIMEOUT",outcome="FAILURE",uri="/hello"} 1672850386800 + api_responses_created{outcome="SUCCESS",uri="/hello"} 1672850385800 + """; assertThat(output).isEqualTo(expected); } 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();