Skip to content

Commit

Permalink
Add BOM definition to the OTel starter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbisutti committed Dec 11, 2023
1 parent 330bf55 commit 93ac7d9
Showing 1 changed file with 68 additions and 6 deletions.
74 changes: 68 additions & 6 deletions content/en/docs/instrumentation/java/automatic/spring-boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,70 @@ Spring Boot starter, see

## Configuration

### OpenTelemetry BOM

You have to import the `opentelemetry-bom` BOM before using the OpenTelemetry starter. We also recommend that you import now the `opentelemetry-instrumentation-bom-alpha`.

We show below how to import the two BOMs with Maven:

```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-bom</artifactId>
<version>{{% param vers.otel %}}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom-alpha</artifactId>
<version>{{% param vers.instrumentation %}}-alpha</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
```

With Gradle and Spring Boot, you have [two ways](https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/) to import a BOM.

You can Gradle’s native bom support:
```kotlin
plugins {
id("java")
id("org.springframework.boot") version "3.2.O"

Check warning on line 57 in content/en/docs/instrumentation/java/automatic/spring-boot.md

View workflow job for this annotation

GitHub Actions / SPELLING check

Unknown word (springframework)
}

dependencies {
implementation(platform(SpringBootPlugin.BOM_COORDINATES))
implementation(platform("io.opentelemetry:opentelemetry-bom:{{% param vers.otel %}}"))
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:{{% param vers.instrumentation %}}-alpha"))
}
```

The other way with Gradle is to use the `io.spring.dependency-management` plugin:

```kotlin
plugins {
id("java")
id("org.springframework.boot") version "3.2.O"

Check warning on line 72 in content/en/docs/instrumentation/java/automatic/spring-boot.md

View workflow job for this annotation

GitHub Actions / SPELLING check

Unknown word (springframework)
id("io.spring.dependency-management") version "1.1.0"
}

dependencyManagement {
imports {
mavenBom("io.opentelemetry:opentelemetry-bom:{{% param vers.otel %}}")
mavenBom("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:{{% param vers.instrumentation %}}-alpha")
}
}
```

{{% alert title="Note" color="info" %}}
Be careful not to mix up the different ways of configuring things with Gradle.
{{% /alert %}}

### OpenTelemetry starter dependency

Add the dependency given below to enable the OpenTelemetry starter.

The OpenTelemetry starter uses OpenTelemetry Spring Boot [auto-configuration].
Expand All @@ -41,16 +105,15 @@ auto-configuration, see the configuration [README].
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
<version>{{% param vers.instrumentation %}}-alpha</version>
</dependency>
</dependencies>
```

{{% /tab %}} {{% tab header="Gradle (`gradle.build`)" lang=Gradle %}}

```groovy
```kotlin
dependencies {
implementation('io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter:{{% param vers.instrumentation %}}-alpha')
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")
}
```

Expand Down Expand Up @@ -102,16 +165,15 @@ With the datasource configuration, you need to add the following dependency:
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
<version>{{% param vers.instrumentation %}}-alpha</version>
</dependency>
</dependencies>
```

{{% /tab %}} {{% tab header="Gradle (`gradle.build`)" lang=Gradle %}}

```groovy
```kotlin
dependencies {
implementation('io.opentelemetry.instrumentation:opentelemetry-jdbc:{{% param vers.instrumentation %}}-alpha')
implementation("io.opentelemetry.instrumentation:opentelemetry-jdbc")
}
```

Expand Down

0 comments on commit 93ac7d9

Please sign in to comment.