Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use spring RestTemplate, RestClient, WebClient #4257

Merged
merged 8 commits into from
Apr 22, 2024
45 changes: 45 additions & 0 deletions content/en/docs/languages/java/automatic/spring-boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,36 @@ 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:

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

```java
public MyService(RestTemplateBuilder restTemplateBuilder) {
this.restTemplate = restTemplateBuilder.build();
}
```

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

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

```java
public MyService(RestClient.Builder restClientBuilder) {
this.restClient = restClientBuilder.build();
}
```

#### Spring Web MVC Autoconfiguration

This feature autoconfigures instrumentation for Spring WebMVC controllers by
Expand All @@ -573,6 +603,21 @@ 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:

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

```java
public MyService(WebClient.Builder webClientBuilder) {
this.webClient = webClientBuilder.build();
}
```

### Additional Instrumentations

#### JDBC Instrumentation
Expand Down