diff --git a/.editorconfig b/.editorconfig index 98cf13e2f..9d16d10c2 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,CODE_OF_CONDUCT.md}] +[{grafana-dashboard-*.json,.editorconfig,lychee.toml,renovate.json5,CODE_OF_CONDUCT.md}] max_line_length = 300 [pom.xml] diff --git a/.github/config/.editorconfig-checker.json b/.github/config/.editorconfig-checker.json index b44b17eaf..5bcecc85d 100644 --- a/.github/config/.editorconfig-checker.json +++ b/.github/config/.editorconfig-checker.json @@ -1,4 +1,4 @@ { - "_comment": "Java files are handled by flint, so editorconfig-checker ignores them.", - "Exclude": [".*\\.java$"] + "Exclude": [".*\\.java$", ".*\\.md$"], + "_comment": "Java files are handled by flint, so editorconfig-checker ignores them." } diff --git a/.github/config/.rumdl.toml b/.github/config/.rumdl.toml new file mode 100644 index 000000000..066c5b40f --- /dev/null +++ b/.github/config/.rumdl.toml @@ -0,0 +1,5 @@ +[MD013] +enabled = true +line-length = 120 +code-blocks = false +tables = false diff --git a/.github/config/.yamllint.yml b/.github/config/.yamllint.yml new file mode 100644 index 000000000..0b3928e3c --- /dev/null +++ b/.github/config/.yamllint.yml @@ -0,0 +1,6 @@ +extends: relaxed + +rules: + document-start: disable + line-length: disable + indentation: enable diff --git a/.github/config/flint.toml b/.github/config/flint.toml index cc437ea00..418612791 100644 --- a/.github/config/flint.toml +++ b/.github/config/flint.toml @@ -9,6 +9,4 @@ exclude = [ ] [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/config/super-linter.env b/.github/config/super-linter.env deleted file mode 100644 index 29797cdb0..000000000 --- a/.github/config/super-linter.env +++ /dev/null @@ -1,24 +0,0 @@ -FILTER_REGEX_EXCLUDE=mvnw|src/main/generated/.*|docs/themes/.*|keystore.pkcs12|.*.java|prometheus-metrics-exporter-opentelemetry-shaded/pom.xml|CODE_OF_CONDUCT.md|CLAUDE.md|CHANGELOG.md -IGNORE_GITIGNORED_FILES=true -JAVA_FILE_NAME=google_checks.xml -LOG_LEVEL=ERROR - -VALIDATE_BASH=true -VALIDATE_EDITORCONFIG=true -VALIDATE_GIT_MERGE_CONFLICT_MARKERS=true -VALIDATE_GITHUB_ACTIONS=true -VALIDATE_JSON_PRETTIER=true -VALIDATE_MARKDOWN=true -VALIDATE_MARKDOWN_PRETTIER=true -VALIDATE_RENOVATE=true -VALIDATE_SHELL_SHFMT=true -VALIDATE_SPELL_CODESPELL=true -VALIDATE_XML=true -VALIDATE_YAML_PRETTIER=true - -FIX_JSON_PRETTIER=true -FIX_MARKDOWN=true -FIX_MARKDOWN_PRETTIER=true -FIX_SHELL_SHFMT=true -FIX_SPELL_CODESPELL=true -FIX_YAML_PRETTIER=true diff --git a/.github/renovate-tracked-deps.json b/.github/renovate-tracked-deps.json index e0d8185f9..a1ae79b74 100644 --- a/.github/renovate-tracked-deps.json +++ b/.github/renovate-tracked-deps.json @@ -67,22 +67,22 @@ "mise.toml": { "mise": [ "actionlint", - "cargo:xmloxide", + "aqua:owenlamont/ryl", + "biome", + "cargo:https://github.com/grafana/flint", "editorconfig-checker", "github:google/google-java-format", - "github:grafana/flint", + "github:jonwiggins/xmloxide", "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", + "ruff", + "rumdl", "shellcheck", "shfmt" ] diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 27afa5920..53ada7433 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#v0.20.3"], + extends: ["config:best-practices", "config:recommended", "github>grafana/flint#v0.20.4"], platformCommit: "enabled", automerge: true, ignorePaths: [ diff --git a/.gitleaksignore b/.gitleaksignore deleted file mode 100644 index 605fefa97..000000000 --- a/.gitleaksignore +++ /dev/null @@ -1,2 +0,0 @@ -/tmp/lint/integration-tests/it-pushgateway/src/test/resources/pushgateway-ssl.yaml:private-key:36 -/github/workspace/integration-tests/it-pushgateway/src/test/resources/pushgateway-ssl.yaml:private-key:36 diff --git a/.markdownlint.yml b/.markdownlint.yml deleted file mode 100644 index 0ba730636..000000000 --- a/.markdownlint.yml +++ /dev/null @@ -1,2 +0,0 @@ -# Line length is enforced by editorconfig-checker via .editorconfig -MD013: false diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1cbfcb82e..000000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -docs/themes/** diff --git a/README.md b/README.md index aa5a0ba52..daef2ac3d 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,15 @@ -[![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 +[![Build][build-badge]][build-workflow] +java 8+ +Apache 2.0 +[build-badge]: https://github.com/prometheus/client_java/actions/workflows/build.yml/badge.svg +[build-workflow]: https://github.com/prometheus/client_java/actions/workflows/build.yml + ## Documentation [https://prometheus.github.io/client_java](https://prometheus.github.io/client_java) diff --git a/docs/content/otel/names.md b/docs/content/otel/names.md index a5425e07f..236c3d629 100644 --- a/docs/content/otel/names.md +++ b/docs/content/otel/names.md @@ -10,10 +10,11 @@ spec, and the [OpenTelemetryExporter](/client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.html) implements that specification. -The goal is, if you set up a pipeline as illustrated below, you will see the same metric names in -the Prometheus server as if you had exposed Prometheus metrics directly. +The goal is, if you set up a pipeline as illustrated below, you will see the same +metric names in the Prometheus server as if you had exposed Prometheus metrics +directly. -![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector](/client_java/images/otel-pipeline.png) +![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector][otel-pipeline] The main steps when converting OpenTelemetry metric names to Prometheus metric names are: @@ -34,3 +35,4 @@ Dots in metric and label names are now supported in the Prometheus Java client l described in [Unicode support]. [Unicode support]: {{< relref "../exporters/unicode.md" >}} +[otel-pipeline]: /client_java/images/otel-pipeline.png diff --git a/docs/content/otel/otlp.md b/docs/content/otel/otlp.md index 568219dd0..184adaf0b 100644 --- a/docs/content/otel/otlp.md +++ b/docs/content/otel/otlp.md @@ -3,10 +3,10 @@ title: OTLP weight: 1 --- -The Prometheus Java client library allows you to push metrics to an OpenTelemetry endpoint using the -OTLP protocol. +The Prometheus Java client library allows you to push metrics to an +OpenTelemetry endpoint using the OTLP protocol. -![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector](/client_java/images/otel-pipeline.png) +![Image of a with the Prometheus client library pushing metrics to an OpenTelemetry collector][otel-pipeline] To implement this, you need to include `prometheus-metrics-exporter` as a dependency @@ -39,11 +39,10 @@ OpenTelemetryExporter.builder() .buildAndStart(); ``` -By default, the `OpenTelemetryExporter` will push metrics every 60 seconds to `localhost:4317` using -`grpc` protocol. You can configure this in code using -the [OpenTelemetryExporter.Builder](/client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.Builder.html), -or at runtime via [`io.prometheus.exporter.opentelemetry.*`]({{< relref "../config/config.md#exporter-opentelemetry-properties" >}}) -properties. +By default, the `OpenTelemetryExporter` will push metrics every 60 seconds to +`localhost:4317` using `grpc` protocol. You can configure this in code using +the [OpenTelemetryExporter.Builder][builder-javadoc], or at runtime via +[`io.prometheus.exporter.opentelemetry.*`][otel-properties] properties. In addition to the Prometheus Java client configuration, the exporter also recognizes standard OpenTelemetry configuration. For example, you can set @@ -56,6 +55,11 @@ attach the for tracing, and use the Prometheus Java client for metrics, it is sufficient to configure the OTel agent because the Prometheus library will pick up the same configuration. -The [examples/example-exporter-opentelemetry](https://github.com/prometheus/client_java/tree/main/examples/example-exporter-opentelemetry) -folder has a Docker compose with a complete end-to-end example, including a Java app, the OTel -collector, and a Prometheus server. +The [examples/example-exporter-opentelemetry][opentelemetry-example] folder has +a Docker compose with a complete end-to-end example, including a Java app, the +OTel collector, and a Prometheus server. + +[builder-javadoc]: /client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.Builder.html +[opentelemetry-example]: https://github.com/prometheus/client_java/tree/main/examples/example-exporter-opentelemetry +[otel-pipeline]: /client_java/images/otel-pipeline.png +[otel-properties]: {{< relref "../config/config.md#exporter-opentelemetry-properties" >}} diff --git a/examples/example-custom-buckets/README.md b/examples/example-custom-buckets/README.md index a7a6a8564..02b0c554a 100644 --- a/examples/example-custom-buckets/README.md +++ b/examples/example-custom-buckets/README.md @@ -163,7 +163,6 @@ docker-compose down ## Further Reading - - [Prometheus Native Histograms Specification](https://prometheus.io/docs/specs/native_histograms/) - [Prometheus Java Client Documentation](https://prometheus.github.io/client_java/) diff --git a/examples/example-exporter-servlet-tomcat/README.md b/examples/example-exporter-servlet-tomcat/README.md index 5a77001f9..fa7dae805 100644 --- a/examples/example-exporter-servlet-tomcat/README.md +++ b/examples/example-exporter-servlet-tomcat/README.md @@ -97,4 +97,6 @@ Use the `histogram_quantile()` function to calculate quantiles from the native h histogram_quantile(0.95, rate(request_duration_seconds[10m])) ``` -![Screenshot showing the 95th Percentile Calculated from a Prometheus Native Histogram](https://github.com/prometheus/client_java/assets/330535/889fb769-9445-4f6f-8540-2b1ddffca55e) +![Screenshot showing the 95th Percentile Calculated from a Prometheus Native Histogram][native-histogram-quantile] + +[native-histogram-quantile]: https://github.com/prometheus/client_java/assets/330535/889fb769-9445-4f6f-8540-2b1ddffca55e diff --git a/examples/example-prometheus-properties/README.md b/examples/example-prometheus-properties/README.md index 2a4e61e80..9faed9201 100644 --- a/examples/example-prometheus-properties/README.md +++ b/examples/example-prometheus-properties/README.md @@ -17,8 +17,8 @@ This should create the file java -jar ./examples/example-prometheus-properties/target/example-prometheus-properties.jar ``` -View the metrics -on [http://localhost:9401/metrics?name[]=request_duration_seconds&name[]=request_size_bytes](http://localhost:9401/metrics?name[]=request_duration_seconds&name[]=request_size_bytes). +View the metrics on +[http://localhost:9401/metrics?name[]=request_duration_seconds&name[]=request_size_bytes][metrics-url]. The example has a `prometheus.properties` file in the classpath with a few examples of how to change settings at runtime. @@ -28,3 +28,5 @@ There are multiple alternative ways to specify the location of the `prometheus.p - Put it in the classpath, like in this example. - Set the environment variable `PROMETHEUS_CONFIG` to the file location. - Set the `prometheus.config` System property to the file location. + +[metrics-url]: http://localhost:9401/metrics?name[]=request_duration_seconds&name[]=request_size_bytes diff --git a/mise.toml b/mise.toml index 18ff6275f..3a4b3d2c2 100644 --- a/mise.toml +++ b/mise.toml @@ -1,27 +1,28 @@ [tools] + +# Linters +actionlint = "1.7.12" +biome = "2.4.12" +"cargo:https://github.com/grafana/flint" = "rev:64fe0a654ca3257f3ce80e05c493caf38e52f47c" +editorconfig-checker = "v3.6.1" +"github:google/google-java-format" = "1.35.0" "go:github.com/gohugoio/hugo" = "v0.160.1" "go:github.com/grafana/oats" = "0.6.1" java = "temurin-25.0.3+9.0.LTS" lychee = "0.23.0" node = "24.15.0" "npm:renovate" = "43.129.1" -protoc = "34.1" - -# Linters -actionlint = "1.7.12" -"cargo:xmloxide" = "0.4.1" -editorconfig-checker = "v3.6.1" -"github:grafana/flint" = "0.20.3" -"github:google/google-java-format" = "1.35.0" -"npm:@biomejs/biome" = "2.4.12" -"npm:markdownlint-cli2" = "0.22.0" -"npm:prettier" = "3.8.3" "pipx:codespell" = "2.4.2" -"pipx:ruff" = "0.15.11" +protoc = "34.1" +rumdl = "0.1.80" shellcheck = "v0.11.0" shfmt = "3.13.1" +"aqua:owenlamont/ryl" = "0.6.0" +ruff = "0.15.11" +"github:jonwiggins/xmloxide" = "v0.4.2" [env] +CARGO_NET_GIT_FETCH_WITH_CLI = "true" FLINT_CONFIG_DIR = ".github/config" # renovate: datasource=github-releases depName=grafana/docker-otel-lgtm LGTM_VERSION = "0.25.0" @@ -115,3 +116,7 @@ java -jar ./benchmarks/target/benchmarks.jar -rf json -rff benchmark-results.jso [tasks."benchmark:generate-summary"] description = "Generate summary from existing benchmark-results.json" run = "python3 ./.mise/tasks/generate_benchmark_summary.py" + +[tasks."lint:pre-commit"] +description = "Fast auto-fix lint (skips slow checks) — for pre-commit/pre-push hooks" +run = "flint run --fix --fast-only"