Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -20,3 +20,11 @@ max_line_length = 120

[{.mise/tasks/build-release.sh,.github/workflows/*.yml}]
max_line_length = 300

[*.java]
# Java line length is handled by google-java-format
max_line_length = off

[*.md]
# Markdown line length is handled by rumdl
max_line_length = off
4 changes: 0 additions & 4 deletions .github/config/.editorconfig-checker.json

This file was deleted.

5 changes: 5 additions & 0 deletions .github/config/.rumdl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MD013]
enabled = true
line-length = 120
code-blocks = false
tables = false
6 changes: 6 additions & 0 deletions .github/config/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: relaxed

rules:
document-start: disable
line-length: disable
indentation: enable
2 changes: 0 additions & 2 deletions .github/config/flint.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
24 changes: 0 additions & 24 deletions .github/config/super-linter.env

This file was deleted.

12 changes: 6 additions & 6 deletions .github/renovate-tracked-deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
2 changes: 0 additions & 2 deletions .gitleaksignore

This file was deleted.

2 changes: 0 additions & 2 deletions .markdownlint.yml

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

<!-- markdownlint-disable MD033 -->

[![Build](https://github.com/prometheus/client_java/actions/workflows/build.yml/badge.svg)](https://github.com/prometheus/client_java/actions/workflows/build.yml) <a href="#"><img src="https://img.shields.io/badge/JDK%20compatibility-8+-blue.svg" alt="java 8+"></a> <a href="#"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="Apache 2.0"></a>
[![Build][build-badge]][build-workflow]
<a href="#"><img src="https://img.shields.io/badge/JDK%20compatibility-8+-blue.svg" alt="java 8+"></a>
<a href="#"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="Apache 2.0"></a>

<!-- markdownlint-enable MD033 -->

[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)
Expand Down
8 changes: 5 additions & 3 deletions docs/content/otel/names.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ spec, and
the [OpenTelemetryExporter](/client_java/api/io/prometheus/metrics/exporter/opentelemetry/OpenTelemetryExporter.html) <!-- editorconfig-checker-disable-line -->
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) <!-- editorconfig-checker-disable-line -->
![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:

Expand All @@ -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
26 changes: 15 additions & 11 deletions docs/content/otel/otlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <!-- editorconfig-checker-disable-line -->
![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

Expand Down Expand Up @@ -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), <!-- editorconfig-checker-disable-line -->
or at runtime via [`io.prometheus.exporter.opentelemetry.*`]({{< relref "../config/config.md#exporter-opentelemetry-properties" >}}) <!-- editorconfig-checker-disable-line -->
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
Expand All @@ -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) <!-- editorconfig-checker-disable-line -->
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" >}}
3 changes: 0 additions & 3 deletions examples/example-custom-buckets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ docker-compose down

## Further Reading

<!-- editorconfig-checker-disable -->
<!-- markdownlint-disable MD013 -->

- [Prometheus Native Histograms Specification](https://prometheus.io/docs/specs/native_histograms/)
- [Prometheus Java Client Documentation](https://prometheus.github.io/client_java/)
- [OpenTelemetry Exponential Histograms](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponentialhistogram)
4 changes: 3 additions & 1 deletion examples/example-exporter-servlet-tomcat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <!-- editorconfig-checker-disable-line -->
![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
6 changes: 4 additions & 2 deletions examples/example-prometheus-properties/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). <!-- editorconfig-checker-disable-line -->
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.
Expand All @@ -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
29 changes: 17 additions & 12 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
[tools]

# Linters
actionlint = "1.7.12"
biome = "2.4.12"
"cargo:https://github.com/grafana/flint" = "rev:7034ab0ad72a34f9dd39388cf8c659f97517c744"
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"
Expand Down Expand Up @@ -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"