---
title: "Out of the box instrumentation"
source: OpenTelemetry Documentation
source_url: https://github.com/open-telemetry/opentelemetry.io
licence: CC-BY-4.0
domain: engineering
subdomain: opentelemetry-docs
date_added: 2026-04-25
---

<?code-excerpt path-base="examples/java/spring-starter"?>

Out of the box instrumentation is available for several frameworks:

{{< tabpane text=true >}} {{% tab "Properties" %}}

| Feature               | Property                                        | Default |
| --------------------- | ----------------------------------------------- | ------- |
| JDBC                  | `otel.instrumentation.jdbc.enabled`             | true    |
| Logback               | `otel.instrumentation.logback-appender.enabled` | true    |
| Logback MDC           | `otel.instrumentation.logback-mdc.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    |

To disable a specific instrumentation:

```yaml
otel:
  instrumentation:
    logback-appender:
      enabled: false
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

In [declarative configuration](../declarative-configuration/), instrumentation
enable/disable uses centralized lists under
`otel.distribution.spring_starter.instrumentation`. The instrumentation name
uses `_` (snake_case), not `-` (kebab-case).

| Feature               | Name               | Default  |
| --------------------- | ------------------ | -------- |
| JDBC                  | `jdbc`             | enabled  |
| Logback               | `logback_appender` | enabled  |
| Logback MDC           | `logback_mdc`      | enabled  |
| Spring Web            | `spring_web`       | enabled  |
| Spring Web MVC        | `spring_webmvc`    | enabled  |
| Spring WebFlux        | `spring_webflux`   | enabled  |
| Kafka                 | `kafka`            | enabled  |
| MongoDB               | `mongo`            | enabled  |
| Micrometer            | `micrometer`       | disabled |
| R2DBC (reactive JDBC) | `r2dbc`            | enabled  |

To disable a specific instrumentation:

```yaml
otel:
  distribution:
    spring_starter:
      instrumentation:
        disabled:
          - logback_appender
```

{{% /tab %}} {{< /tabpane >}}

## Turn on instrumentations selectively

{{< tabpane text=true >}} {{% tab "Properties" %}}

To use only specific instrumentations, turn off all the instrumentations first
and then turn on instrumentations one by one:

```yaml
otel:
  instrumentation:
    common:
      default-enabled: false
    jdbc:
      enabled: true
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

In [declarative configuration](../declarative-configuration/), set
`default_enabled` to `false` and list the instrumentations you want in
`enabled`:

```yaml
otel:
  distribution:
    spring_starter:
      instrumentation:
        default_enabled: false
        enabled:
          - jdbc
```

{{% /tab %}} {{< /tabpane >}}

## Common instrumentation configuration

Common properties for all database instrumentations:

{{< tabpane text=true >}} {{% tab "Properties" %}}

Enables the DB statement sanitization for all database instrumentations:

```yaml
otel:
  instrumentation:
    common:
      db-statement-sanitizer:
        enabled: true # default: true
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

Enables the DB statement sanitization for all database instrumentations:

```yaml
otel:
  instrumentation/development:
    java:
      common:
        database:
          statement_sanitizer:
            enabled: true
```

{{% /tab %}} {{< /tabpane >}}

## JDBC Instrumentation

{{< tabpane text=true >}} {{% tab "Properties" %}}

Enables the DB statement sanitization for JDBC:

```yaml
otel:
  instrumentation:
    jdbc:
      statement-sanitizer:
        enabled: true # default: true
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

Enables the DB statement sanitization for JDBC:

```yaml
otel:
  instrumentation/development:
    java:
      jdbc:
        statement_sanitizer:
          enabled: true
```

{{% /tab %}} {{< /tabpane >}}

## Logback

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

{{< tabpane text=true >}} {{% tab "Properties" %}}

| Property                                         | Type    | Default | Description                                                                                                                                     |
| ------------------------------------------------ | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `experimental-log-attributes`                    | Boolean | false   | Enable the capture of experimental log attributes `thread.name` and `thread.id`.                                                                |
| `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. |
| `experimental.capture-marker-attribute`          | Boolean | false   | Enable the capture of Logback markers as attributes.                                                                                            |
| `experimental.capture-key-value-pair-attributes` | Boolean | false   | Enable the capture of Logback key value pairs as attributes.                                                                                    |
| `experimental.capture-logger-context-attributes` | Boolean | false   | Enable the capture of Logback logger context properties as attributes.                                                                          |
| `experimental.capture-mdc-attributes`            | String  |         | Comma separated list of MDC attributes to capture. Use the wildcard character `*` to capture all attributes.                                    |

```yaml
otel:
  instrumentation:
    logback-appender:
      experimental-log-attributes: false
      experimental:
        capture-code-attributes: false
        capture-marker-attribute: false
        capture-key-value-pair-attributes: false
        capture-logger-context-attributes: false
        capture-mdc-attributes: '*'
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

| Property                                        | Type    | Default | Description                                                                                                                                     |
| ----------------------------------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `experimental_log_attributes/development`       | Boolean | false   | Enable the capture of experimental log attributes `thread.name` and `thread.id`.                                                                |
| `capture_code_attributes/development`           | Boolean | false   | Enable the capture of [source code attributes][]. Note that capturing source code attributes at logging sites might add a performance overhead. |
| `capture_marker_attribute/development`          | Boolean | false   | Enable the capture of Logback markers as attributes.                                                                                            |
| `capture_key_value_pair_attributes/development` | Boolean | false   | Enable the capture of Logback key value pairs as attributes.                                                                                    |
| `capture_logger_context_attributes/development` | Boolean | false   | Enable the capture of Logback logger context properties as attributes.                                                                          |
| `capture_mdc_attributes/development`            | String  |         | Comma separated list of MDC attributes to capture. Use the wildcard character `*` to capture all attributes.                                    |

```yaml
otel:
  instrumentation/development:
    java:
      logback_appender:
        experimental_log_attributes/development: false
        capture_code_attributes/development: false
        capture_marker_attribute/development: false
        capture_key_value_pair_attributes/development: false
        capture_logger_context_attributes/development: false
        capture_mdc_attributes/development: '*'
```

{{% /tab %}} {{< /tabpane >}}

[source code attributes]:
  /docs/specs/semconv/general/attributes/#source-code-attributes

Alternatively, you can enable these features by adding the OpenTelemetry Logback
appender in your `logback.xml` or `logback-spring.xml` file:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            </pattern>
        </encoder>
    </appender>
    <appender name="OpenTelemetry"
        class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
        <captureExperimentalAttributes>false</captureExperimentalAttributes>
        <captureCodeAttributes>true</captureCodeAttributes>
        <captureMarkerAttribute>true</captureMarkerAttribute>
        <captureKeyValuePairAttributes>true</captureKeyValuePairAttributes>
        <captureLoggerContext>true</captureLoggerContext>
        <captureMdcAttributes>*</captureMdcAttributes>
    </appender>
    <root level="INFO">
        <appender-ref ref="console"/>
        <appender-ref ref="OpenTelemetry"/>
    </root>
</configuration>
```

## Spring Web Autoconfiguration

Provides autoconfiguration for the `RestTemplate` trace interceptor defined in
[opentelemetry-spring-web-3.1](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-web/spring-web-3.1/library).
This autoconfiguration instruments all requests sent using Spring `RestTemplate`
beans by applying a `RestTemplate` bean post processor. This feature is
supported for spring web versions 3.1+. To learn more about the OpenTelemetry
`RestTemplate` interceptor, see
[opentelemetry-spring-web-3.1](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-web/spring-web-3.1/library).

The following ways of creating a `RestTemplate` are supported:


<?code-excerpt "src/main/java/otel/RestTemplateConfig.java"?>
```java
package otel;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {

  @Bean
  public RestTemplate restTemplate() {
    return new RestTemplate();
  }
}
```

<?code-excerpt "src/main/java/otel/RestTemplateController.java"?>
```java
package otel;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class RestTemplateController {

  private final RestTemplate restTemplate;

  public RestTemplateController(RestTemplateBuilder restTemplateBuilder) {
    restTemplate = restTemplateBuilder.rootUri("http://localhost:8080").build();
  }
}
```


The following ways of creating a `RestClient` are supported:


<?code-excerpt "src/main/java/otel/RestClientConfig.java"?>
```java
package otel;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

@Configuration
public class RestClientConfig {

  @Bean
  public RestClient restClient() {
    return RestClient.create();
  }
}
```

<?code-excerpt "src/main/java/otel/RestClientController.java"?>
```java
package otel;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestClient;

@RestController
public class RestClientController {

  private final RestClient restClient;

  public RestClientController(RestClient.Builder restClientBuilder) {
    restClient = restClientBuilder.baseUrl("http://localhost:8080").build();
  }
}
```


As it's possible with the Java agent, you can configure the capture of the
following entities:

- [HTTP request and response headers](/docs/zero-code/java/agent/instrumentation/http/#capturing-http-request-and-response-headers)
- [Known HTTP methods](/docs/zero-code/java/agent/instrumentation/http/#configuring-known-http-methods)
- [Experimental HTTP telemetry](/docs/zero-code/java/agent/instrumentation/http/#enabling-experimental-http-telemetry)

## Spring Web MVC Autoconfiguration

This feature autoconfigures instrumentation for Spring WebMVC controllers by
adding a
[telemetry producing servlet `Filter`](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/WebMvcTelemetryProducingFilter.java)
bean to the application context. The filter decorates the request execution with
a server span, propagating the incoming tracing context if received in the HTTP
request. To learn more about the OpenTelemetry Spring WebMVC instrumentation,
see the
[opentelemetry-spring-webmvc-5.3 instrumentation library](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library).

As it's possible with the Java agent, you can configure the capture of the
following entities:

- [HTTP request and response headers](/docs/zero-code/java/agent/instrumentation/http/#capturing-http-request-and-response-headers)
- [Known HTTP methods](/docs/zero-code/java/agent/instrumentation/http/#configuring-known-http-methods)
- [Experimental HTTP telemetry](/docs/zero-code/java/agent/instrumentation/http/#enabling-experimental-http-telemetry)

## Spring WebFlux Autoconfiguration

Provides autoconfigurations for the OpenTelemetry WebClient ExchangeFilter
defined in
[opentelemetry-spring-webflux-5.3](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-webflux/spring-webflux-5.3/library).
This autoconfiguration instruments all outgoing HTTP requests sent using
Spring's WebClient and WebClient Builder beans by applying a bean post
processor. This feature is supported for spring webflux versions 5.0+. For
details, see
[opentelemetry-spring-webflux-5.3](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-webflux/spring-webflux-5.3/library).

The following ways of creating a `WebClient` are supported:


<?code-excerpt "src/main/java/otel/WebClientConfig.java"?>
```java
package otel;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class WebClientConfig {

  @Bean
  public WebClient webClient() {
    return WebClient.create();
  }
}
```

<?code-excerpt "src/main/java/otel/WebClientController.java"?>
```java
package otel;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;

@RestController
public class WebClientController {

  private final WebClient webClient;

  public WebClientController(WebClient.Builder webClientBuilder) {
    webClient = webClientBuilder.baseUrl("http://localhost:8080").build();
  }
}
```


## Kafka Instrumentation

Provides autoconfiguration for the Kafka client instrumentation.

{{< tabpane text=true >}} {{% tab "Properties" %}}

Enables the capture of experimental span attributes for Kafka:

```yaml
otel:
  instrumentation:
    kafka:
      experimental-span-attributes: false # default: false
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

Enables the capture of experimental span attributes for Kafka:

```yaml
otel:
  instrumentation/development:
    java:
      kafka:
        experimental_span_attributes/development: false
```

{{% /tab %}} {{< /tabpane >}}

## Micrometer Instrumentation

Provides autoconfiguration for the Micrometer to OpenTelemetry bridge.

## MongoDB Instrumentation

Provides autoconfiguration for the MongoDB client instrumentation.

{{< tabpane text=true >}} {{% tab "Properties" %}}

Enables the DB statement sanitization for MongoDB:

```yaml
otel:
  instrumentation:
    mongo:
      statement-sanitizer:
        enabled: true # default: true
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

Enables the DB statement sanitization for MongoDB:

```yaml
otel:
  instrumentation/development:
    java:
      mongo:
        statement_sanitizer:
          enabled: true
```

{{% /tab %}} {{< /tabpane >}}

## R2DBC Instrumentation

Provides autoconfiguration for the OpenTelemetry R2DBC instrumentation.

{{< tabpane text=true >}} {{% tab "Properties" %}}

Enables the DB statement sanitization for R2DBC:

```yaml
otel:
  instrumentation:
    r2dbc:
      statement-sanitizer:
        enabled: true # default: true
```

{{% /tab %}} {{% tab "Declarative Configuration" %}}

Enables the DB statement sanitization for R2DBC:

```yaml
otel:
  instrumentation/development:
    java:
      r2dbc:
        statement_sanitizer:
          enabled: true
```

{{% /tab %}} {{< /tabpane >}}
