From 601ce6c35a9a87cf6260b11e0a07dcf78db1734d Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 24 May 2024 17:08:26 +0200 Subject: [PATCH] spring starter 2.4.0 update (#4528) --- .../docs/zero-code/java/spring-boot/_index.md | 103 ++++++++---------- 1 file changed, 44 insertions(+), 59 deletions(-) diff --git a/content/en/docs/zero-code/java/spring-boot/_index.md b/content/en/docs/zero-code/java/spring-boot/_index.md index d3c2054f4bae..bb700dc8545d 100644 --- a/content/en/docs/zero-code/java/spring-boot/_index.md +++ b/content/en/docs/zero-code/java/spring-boot/_index.md @@ -419,12 +419,23 @@ 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 @@ -432,8 +443,8 @@ 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. | @@ -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 - - - io.opentelemetry.instrumentation - opentelemetry-jdbc - - -``` - -{{% /tab %}} {{% tab header="Gradle (`gradle.build`)" lang=Gradle %}} - -```kotlin -dependencies { - implementation("io.opentelemetry.instrumentation:opentelemetry-jdbc") -} -``` - -{{% /tab %}} {{< /tabpane>}} +### Additional Instrumentations #### Log4j2 Instrumentation @@ -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 @@ -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;