Skip to content

Commit f07e82c

Browse files
authored
Merge branch 'main' into add-caffeine-guava-instrumentation-to-bom
2 parents 14c60ee + d6572b7 commit f07e82c

File tree

17 files changed

+1059
-942
lines changed

17 files changed

+1059
-942
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Set up JDK
15-
uses: actions/setup-java@v4
14+
- name: Setup ASDF
15+
uses: equisoft-actions/with-asdf-vm@v2
16+
- name: Cache local Maven repository
17+
uses: actions/cache@v4
1618
with:
17-
java-version: 17
18-
distribution: temurin
19-
cache: 'maven'
20-
- name: Install Protoc
21-
run: |
22-
VERSION=28.2
23-
curl -sL -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v$VERSION/protoc-$VERSION-linux-x86_64.zip
24-
sudo unzip protoc.zip -d /usr/local
19+
path: ~/.m2/repository
20+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
21+
restore-keys: |
22+
${{ runner.os }}-maven-
2523
- name: Run the Maven verify phase
2624
env:
2725
PROTO_GENERATION: true
2826
REQUIRE_PROTO_UP_TO_DATE: true
2927
run: |
28+
echo "Java version: $(java -version) in $(which java), Maven version: $(mvn -v)"
29+
echo "JAVA_HOME: $JAVA_HOME"
3030
./mvnw clean install
3131
./mvnw javadoc:javadoc -P javadoc # just to check if javadoc is generated

.github/workflows/github-pages.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ jobs:
3434
HUGO_VERSION: 0.115.4
3535
steps:
3636
- uses: actions/checkout@v4
37+
with:
38+
fetch-tags: 'true'
39+
fetch-depth: 0
3740
- name: Set up JDK
3841
uses: actions/setup-java@v4
3942
with:
4043
java-version: 17
4144
distribution: temurin
4245
cache: 'maven'
46+
- name: Set release version
47+
run: ./scripts/set-release-version-github-pages.sh
4348
- name: Install Hugo CLI
4449
run: |
4550
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \

.tool-versions

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
java temurin-17.0.7+7
1+
java temurin-17.0.13+11
2+
protoc 28.3

docs/content/getting-started/quickstart.md

Lines changed: 94 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,134 @@
11
---
22
title: Quickstart
3-
weight: 1
3+
weight: 0
44
---
55

66
This tutorial shows the quickest way to get started with the Prometheus Java metrics library.
77

8+
{{< toc >}}
9+
810
# Dependencies
911

1012
We use the following dependencies:
1113

1214
* `prometheus-metrics-core` is the actual metrics library.
1315
* `prometheus-metrics-instrumentation-jvm` provides out-of-the-box JVM metrics.
1416
* `prometheus-metrics-exporter-httpserver` is a standalone HTTP server for exposing Prometheus metrics.
15-
{{< tabs "uniqueid" >}}
17+
{{< tabs "deps" >}}
1618
{{< tab "Gradle" >}}
1719
```
18-
implementation 'io.prometheus:prometheus-metrics-core:1.0.0'
19-
implementation 'io.prometheus:prometheus-metrics-instrumentation-jvm:1.0.0'
20-
implementation 'io.prometheus:prometheus-metrics-exporter-httpserver:1.0.0'
20+
implementation 'io.prometheus:prometheus-metrics-core:$version'
21+
implementation 'io.prometheus:prometheus-metrics-instrumentation-jvm:$version'
22+
implementation 'io.prometheus:prometheus-metrics-exporter-httpserver:$version'
2123
```
2224
{{< /tab >}}
2325
{{< tab "Maven" >}}
2426
```xml
2527
<dependency>
2628
<groupId>io.prometheus</groupId>
2729
<artifactId>prometheus-metrics-core</artifactId>
28-
<version>1.0.0</version>
30+
<version>$version</version>
2931
</dependency>
3032
<dependency>
3133
<groupId>io.prometheus</groupId>
3234
<artifactId>prometheus-metrics-instrumentation-jvm</artifactId>
33-
<version>1.0.0</version>
35+
<version>$version</version>
3436
</dependency>
3537
<dependency>
3638
<groupId>io.prometheus</groupId>
3739
<artifactId>prometheus-metrics-exporter-httpserver</artifactId>
38-
<version>1.0.0</version>
40+
<version>$version</version>
3941
</dependency>
4042
```
4143
{{< /tab >}}
4244
{{< /tabs >}}
4345

4446
There are alternative exporters as well, for example if you are using a Servlet container like Tomcat or Undertow you might want to use `prometheus-exporter-servlet-jakarta` rather than a standalone HTTP server.
4547

48+
# Dependency management
49+
50+
A Bill of Material
51+
([BOM](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms))
52+
ensures that versions of dependencies (including transitive ones) are aligned.
53+
This is especially important when using Spring Boot, which manages some of the dependencies of the project.
54+
55+
You should omit the version number of the dependencies in your build file if you are using a BOM.
56+
57+
{{< tabs "bom" >}}
58+
{{< tab "Gradle" >}}
59+
60+
You have two ways to import a BOM.
61+
62+
First, you can use the Gradle’s native BOM support by adding `dependencies`:
63+
64+
```kotlin
65+
import org.springframework.boot.gradle.plugin.SpringBootPlugin
66+
67+
plugins {
68+
id("java")
69+
id("org.springframework.boot") version "3.2.O" // if you are using Spring Boot
70+
}
71+
72+
dependencies {
73+
implementation(platform(SpringBootPlugin.BOM_COORDINATES)) // if you are using Spring Boot
74+
implementation(platform("io.prometheus:prometheus-metrics-bom:$version"))
75+
}
76+
```
77+
78+
The other way with Gradle is to use `dependencyManagement`:
79+
80+
```kotlin
81+
plugins {
82+
id("java")
83+
id("org.springframework.boot") version "3.2.O" // if you are using Spring Boot
84+
id("io.spring.dependency-management") version "1.1.0" // if you are using Spring Boot
85+
}
86+
87+
dependencyManagement {
88+
imports {
89+
mavenBom("io.prometheus:prometheus-metrics-bom:$version")
90+
}
91+
}
92+
```
93+
94+
{{< hint type=note >}}
95+
96+
Be careful not to mix up the different ways of configuring things with Gradle.
97+
For example, don't use
98+
`implementation(platform("io.prometheus:prometheus-metrics-bom:$version"))`
99+
with the `io.spring.dependency-management` plugin.
100+
101+
{{< /hint >}}
102+
103+
{{< /tab >}}
104+
{{< tab "Maven" >}}
105+
106+
{{< hint type=note >}}
107+
108+
Import the Prometheus Java metrics BOMs before any other BOMs in your
109+
project. For example, if you import the `spring-boot-dependencies` BOM, you have
110+
to declare it after the Prometheus Java metrics BOMs.
111+
112+
{{< /hint >}}
113+
114+
The following example shows how to import the Prometheus Java metrics BOMs using Maven:
115+
116+
```xml
117+
<dependencyManagement>
118+
<dependencies>
119+
<dependency>
120+
<groupId>io.prometheus</groupId>
121+
<artifactId>prometheus-metrics-bom</artifactId>
122+
<version>$version</version>
123+
<type>pom</type>
124+
<scope>import</scope>
125+
</dependency>
126+
</dependencies>
127+
</dependencyManagement>
128+
```
129+
130+
{{< /tab >}}
131+
{{< /tabs >}}
46132

47133
# Example Application
48134

examples/example-exemplars-tail-sampling/example-greeting-service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>org.apache.tomcat.embed</groupId>
4040
<artifactId>tomcat-embed-core</artifactId>
41-
<version>11.0.0</version>
41+
<version>11.0.1</version>
4242
</dependency>
4343
</dependencies>
4444

examples/example-exemplars-tail-sampling/example-hello-world-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>org.apache.tomcat.embed</groupId>
4040
<artifactId>tomcat-embed-core</artifactId>
41-
<version>11.0.0</version>
41+
<version>11.0.1</version>
4242
</dependency>
4343
</dependencies>
4444

examples/example-exporter-servlet-tomcat/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>org.apache.tomcat.embed</groupId>
4040
<artifactId>tomcat-embed-core</artifactId>
41-
<version>11.0.0</version>
41+
<version>11.0.1</version>
4242
</dependency>
4343
</dependencies>
4444

integration-tests/it-exporter/it-exporter-servlet-tomcat-sample/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>org.apache.tomcat.embed</groupId>
3535
<artifactId>tomcat-embed-core</artifactId>
36-
<version>11.0.0</version>
36+
<version>11.0.1</version>
3737
</dependency>
3838
</dependencies>
3939

integration-tests/it-exporter/it-exporter-test/src/test/java/io/prometheus/metrics/it/exporter/test/ExporterIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import io.prometheus.client.it.common.LogConsumer;
88
import io.prometheus.client.it.common.Volume;
9-
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_2.Metrics;
9+
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_3.Metrics;
1010
import java.io.ByteArrayInputStream;
1111
import java.io.IOException;
1212
import java.io.InputStream;

prometheus-metrics-core/src/test/java/io/prometheus/metrics/core/metrics/CounterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfigTestUtil;
99
import io.prometheus.metrics.expositionformats.PrometheusProtobufWriter;
1010
import io.prometheus.metrics.expositionformats.TextFormatUtil;
11-
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_2.Metrics;
11+
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_28_3.Metrics;
1212
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
1313
import io.prometheus.metrics.model.snapshots.Exemplar;
1414
import io.prometheus.metrics.model.snapshots.Label;

0 commit comments

Comments
 (0)