Skip to content

Commit

Permalink
spring starter 2.4.0 update (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger authored May 24, 2024
1 parent 538fba5 commit 601ce6c
Showing 1 changed file with 44 additions and 59 deletions.
103 changes: 44 additions & 59 deletions content/en/docs/zero-code/java/spring-boot/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,21 +419,32 @@ springBoot {

Automatic instrumentation is available for several frameworks:

| Feature | Property | Default Value |
| -------------- | ----------------------------------------------- | ------------- |
| Logback | `otel.instrumentation.logback-appender.enabled` | true |
| Spring Web | `otel.instrumentation.spring-web.enabled` | true |
| Spring Web MVC | `otel.instrumentation.spring-webmvc.enabled` | true |
| Spring WebFlux | `otel.instrumentation.spring-webflux.enabled` | true |
| Feature | Property | Default Value |
| --------------------- | ----------------------------------------------- | ------------- |
| JDBC | `otel.instrumentation.jdbc.enabled` | true |
| Logback | `otel.instrumentation.logback-appender.enabled` | true |
| Spring Web | `otel.instrumentation.spring-web.enabled` | true |
| Spring Web MVC | `otel.instrumentation.spring-webmvc.enabled` | true |
| Spring WebFlux | `otel.instrumentation.spring-webflux.enabled` | true |
| Kafka | `otel.instrumentation.kafka.enabled` | true |
| MongoDB | `otel.instrumentation.mongo.enabled` | true |
| Micrometer | `otel.instrumentation.micrometer.enabled` | false |
| R2DBC (reactive JDBC) | `otel.instrumentation.r2dbc.enabled` | true |

#### JDBC Instrumentation

| System property | Type | Default | Description |
| ------------------------------------------------------- | ------- | ------- | -------------------------------------- |
| `otel.instrumentation.jdbc.statement-sanitizer.enabled` | Boolean | true | Enables the DB statement sanitization. |

#### Logback

You can enable experimental features with system properties to capture
attributes :

| System property | Type | Default | Description |
| -------------------------------------------------------------------------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --- |
| `otel.instrumentation.logback-appender.experimental-log-attributes` | Boolean | false | Enable the capture of experimental log attributes `thread.name` and `thread.id`. | |
| -------------------------------------------------------------------------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `otel.instrumentation.logback-appender.experimental-log-attributes` | Boolean | false | Enable the capture of experimental log attributes `thread.name` and `thread.id`. |
| `otel.instrumentation.logback-appender.experimental.capture-code-attributes` | Boolean | false | Enable the capture of [source code attributes]. Note that capturing source code attributes at logging sites might add a performance overhead. |
| `otel.instrumentation.logback-appender.experimental.capture-marker-attribute` | Boolean | false | Enable the capture of Logback markers as attributes. |
| `otel.instrumentation.logback-appender.experimental.capture-key-value-pair-attributes` | Boolean | false | Enable the capture of Logback key value pairs as attributes. |
Expand Down Expand Up @@ -549,65 +560,35 @@ public MyService(WebClient.Builder webClientBuilder) {
}
```

### Additional Instrumentations

#### JDBC Instrumentation
#### Kafka Instrumentation

You have two ways to enable the JDBC instrumentation with the OpenTelemetry
starter.
Provides autoconfiguration for the Kafka client instrumentation.

If your application does not declare `DataSource` bean, you can update your
`application.properties` file to have the data source URL starting with
`jdbc:otel:` and set the driver class to
`io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver`.
| System property | Type | Default | Description |
| --------------------------------------------------------- | ------- | ------- | ---------------------------------------------------- |
| `otel.instrumentation.kafka.experimental-span-attributes` | Boolean | false | Enables the capture of experimental span attributes. |

```properties
spring.datasource.url=jdbc:otel:h2:mem:db
spring.datasource.driver-class-name=io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver
```
#### Micrometer Instrumentation

You can also wrap the `DataSource` bean in an
`io.opentelemetry.instrumentation.jdbc.datasource.OpenTelemetryDataSource`:
Provides autoconfiguration for the Micrometer to OpenTelemetry bridge.

```java
import io.opentelemetry.instrumentation.jdbc.datasource.JdbcTelemetry;
#### MongoDB Instrumentation

@Configuration
public class DataSourceConfig {
Provides autoconfiguration for the MongoDB client instrumentation.

@Bean
public DataSource dataSource(OpenTelemetry openTelemetry) {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
//Data source configurations
DataSource dataSource = dataSourceBuilder.build();
return JdbcTelemetry.create(openTelemetry).wrap(dataSource);
}
| System property | Type | Default | Description |
| -------------------------------------------------------- | ------- | ------- | -------------------------------------- |
| `otel.instrumentation.mongo.statement-sanitizer.enabled` | Boolean | true | Enables the DB statement sanitization. |

}
```
#### R2DBC Instrumentation

With the datasource configuration, you need to add the following dependency:
Provides autoconfiguration for the OpenTelemetry R2DBC instrumentation.

{{< tabpane text=true >}} {{% tab header="Maven (`pom.xml`)" lang=Maven %}}
| System property | Type | Default | Description |
| -------------------------------------------------------- | ------- | ------- | -------------------------------------- |
| `otel.instrumentation.r2dbc.statement-sanitizer.enabled` | Boolean | true | Enables the DB statement sanitization. |

```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
</dependency>
</dependencies>
```

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

```kotlin
dependencies {
implementation("io.opentelemetry.instrumentation:opentelemetry-jdbc")
}
```

{{% /tab %}} {{< /tabpane>}}
### Additional Instrumentations

#### Log4j2 Instrumentation

Expand All @@ -631,6 +612,10 @@ You can find more configuration options for the OpenTelemetry appender in the
[Log4j](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/README.md)
instrumentation library.

| System property | Type | Default | Description |
| --------------------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------- |
| `otel.instrumentation.log4j-appender.enabled` | Boolean | true | Enables the configuration of the Log4j OpenTelemetry appender with an `OpenTelemetry` instance. |

#### Instrumentation Annotations

This feature uses spring-aop to wrap methods annotated with `@WithSpan` in a
Expand All @@ -641,9 +626,9 @@ span by annotating the method parameters with `@SpanAttribute`.
> spring application context. To learn more about aspect weaving in spring, see
> [spring-aop](https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop).
| Feature | Property | Default Value | ConditionalOnClass |
| ----------- | ------------------------------------------ | ------------- | ------------------ |
| `@WithSpan` | `otel.instrumentation.annotations.enabled` | true | WithSpan, Aspect |
| Feature | Property | Default Value | Description |
| ----------- | ------------------------------------------ | ------------- | --------------------------------- |
| `@WithSpan` | `otel.instrumentation.annotations.enabled` | true | Enables the WithSpan annotations. |

```java
import org.springframework.stereotype.Component;
Expand Down

0 comments on commit 601ce6c

Please sign in to comment.