Skip to content

Commit

Permalink
Small spring fixes (open-telemetry#4677)
Browse files Browse the repository at this point in the history
Co-authored-by: Trask Stalnaker <[email protected]>
Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2024
1 parent 8100744 commit 61a26ba
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions content/en/docs/languages/java/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,23 @@ import io.opentelemetry.api.GlobalOpenTelemetry;
Tracer tracer = GlobalOpenTelemetry.getTracer("application");
```

If you are using Spring Boot, you can add the following bean to your
`@SpringBootApplication` class - to acquire a `Tracer` as in the
[Spring Boot starter](#acquiring-a-tracer-in-spring-boot-starter) section below:

```java
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;

@Configuration
public class OpenTelemetryConfig {
@Bean
public OpenTelemetry openTelemetry() {
return GlobalOpenTelemetry.get();
}
}
```

### Acquiring a tracer in Spring Boot starter

If you are using the [Spring Boot starter], you can acquire a `Tracer` from the
Expand Down Expand Up @@ -1257,6 +1274,23 @@ import io.opentelemetry.api.GlobalOpenTelemetry;
Meter meter = GlobalOpenTelemetry.getMeter("application");
```

If you are using Spring Boot, you can add the following bean to your
`@SpringBootApplication` class - to acquire a `Meter` as in the
[Spring Boot starter](#acquiring-a-meter-in-spring-boot-starter) section below:

```java
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;

@Configuration
public class OpenTelemetryConfig {
@Bean
public OpenTelemetry openTelemetry() {
return GlobalOpenTelemetry.get();
}
}
```

### Acquiring a meter in Spring Boot starter

If you are using the [Spring Boot starter], you can acquire a `Meter` from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ application. For the pros and cons, see [Java zero-code instrumentation](..).

### Compatibility

The OpenTelemetry Spring Boot starter works with Spring Boot 2.6+ and 3.0+, and
The OpenTelemetry Spring Boot starter works with Spring Boot 2.6+ and 3.1+, and
Spring Boot native image applications. The
[opentelemetry-java-examples/spring-native](https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/spring-native)
repository contains an example of a Spring Boot Native image application
Expand Down

0 comments on commit 61a26ba

Please sign in to comment.