Skip to content

Commit

Permalink
Add blog spot for Spring native images (#3612)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbisutti authored Dec 8, 2023
1 parent 4750f0f commit 210e9c6
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
80 changes: 80 additions & 0 deletions content/en/blog/2023/spring-native/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Observe your Spring Native Image application with OpenTelemetry
linkTitle: Observe Spring Native
date: 2023-12-08
author: >-
[Jean Bisutti](https://github.com/jeanbisutti) (Microsoft)
cSpell:ignore: bisutti datasource logback
---

The [OpenTelemetry Java agent](/docs/instrumentation/java/automatic) is a
convenient and well-established way to instrument Java applications. However, as
of today
[it is not possible to use it with GraalVM Native Images](https://github.com/oracle/graal/issues/1065).

To provide you with an easy and seamless way for Spring Boot Native Image
application nevertheless, the OpenTelemetry Java contributors have improved the
existing OpenTelemetry Spring Boot Starter to work well with Spring Boot Native
Image applications. Read on to learn more!

## A history of the last months

The OpenTelemetry Spring Boot Starter allows to add OpenTelemetry to your
application without byte code instrumentation. The OpenTelemetry Java
contributors have used this to instrument Spring Boot Native Images. By adding
the starter dependency to your project, you will benefit from an OTLP exports of
logs (added the last months), spans and metrics, with an auto-instrumentation
for Spring HTTP frameworks (updated the last months to make it work with Spring
Boot 3) out of the box:

```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
<version>1.32.0-alpha</version>
</dependency>
</dependencies>
```

To get even more visibility, the Starter can be combined with
[instrumentation libraries](/docs/instrumentation/java/libraries/). For this
purpose, the OpenTelemetry Java contributors have improved the JDBC (database)
libraries and logging instrumentation libraries. For example, for the Logback
logging library, they have added GraalVM configuration to make the library work
in native mode[^1].

Furthermore, they have worked to reduce the configuration to set up the logging
and database instrumentation with the Starter. For example, if your application
does not declare a DataSource bean, you can enable the database by simply adding
two properties in the `application.properties` file:

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

Read the [documentation](/docs/instrumentation/java/automatic/spring-boot/) of
the OpenTelemetry Spring Boot Starter to learn more. You can use
[opentelemetry-java-examples/spring-native](https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/spring-native)
to run a Spring Boot Native Image application and look at the generated logs as
well as HTTP and database telemetry data.

Finally, the OpenTelemetry Java contributors have added GraalVM Native automatic
tests to the OpenTelemetry Java project to detect regressions related to the
native mode execution.

## What’s next?

The OpenTelemetry Java contributors expect to be able to enable automatic
logging and database instrumentation configuration.

If you try out the OpenTelemetry Spring Boot Starter, share your thoughts and
experiences via
[GitHub discussions](https://github.com/open-telemetry/opentelemetry-java/discussions)
or the [#otel-java](https://cloud-native.slack.com/archives/C014L2KCTE3)
[CNCF Slack](https://slack.cncf.io) channel.

[^1]:
Spring Boot Native Image applications
[do not support Log4j2 logging library](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-GraalVM).
24 changes: 24 additions & 0 deletions static/refcache.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
"StatusCode": 206,
"LastSeen": "2023-06-30T09:37:46.480932-04:00"
},
"https://cloud-native.slack.com/archives/C014L2KCTE3": {
"StatusCode": 200,
"LastSeen": "2023-12-08T11:19:16.128163+01:00"
},
"https://cloud-native.slack.com/archives/C01N5UCHTEH": {
"StatusCode": 200,
"LastSeen": "2023-06-30T09:38:12.370641-04:00"
Expand Down Expand Up @@ -2371,6 +2375,10 @@
"StatusCode": 200,
"LastSeen": "2023-10-23T22:46:44.940049+02:00"
},
"https://github.com/jeanbisutti": {
"StatusCode": 200,
"LastSeen": "2023-12-08T11:19:13.539577+01:00"
},
"https://github.com/jenniferplusplus/opentelemetry-instrumentation-bullmq": {
"StatusCode": 200,
"LastSeen": "2023-06-30T08:33:32.788394-04:00"
Expand Down Expand Up @@ -3203,6 +3211,10 @@
"StatusCode": 200,
"LastSeen": "2023-11-01T21:52:02.990981-04:00"
},
"https://github.com/open-telemetry/opentelemetry-java/discussions": {
"StatusCode": 200,
"LastSeen": "2023-12-08T11:19:15.572149+01:00"
},
"https://github.com/open-telemetry/opentelemetry-java/releases": {
"StatusCode": 200,
"LastSeen": "2023-06-30T08:47:15.179862-04:00"
Expand Down Expand Up @@ -3731,6 +3743,10 @@
"StatusCode": 200,
"LastSeen": "2023-06-30T08:42:08.536962-04:00"
},
"https://github.com/oracle/graal/issues/1065": {
"StatusCode": 200,
"LastSeen": "2023-12-08T11:19:14.694346+01:00"
},
"https://github.com/orgs/open-telemetry/projects/41/views/1": {
"StatusCode": 200,
"LastSeen": "2023-06-30T09:42:42.642961-04:00"
Expand Down Expand Up @@ -3839,6 +3855,10 @@
"StatusCode": 200,
"LastSeen": "2023-06-30T09:27:42.016103-04:00"
},
"https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-GraalVM": {
"StatusCode": 200,
"LastSeen": "2023-12-08T11:19:16.63837+01:00"
},
"https://github.com/statsd/statsd": {
"StatusCode": 200,
"LastSeen": "2023-06-30T08:39:57.115625-04:00"
Expand Down Expand Up @@ -4907,6 +4927,10 @@
"StatusCode": 206,
"LastSeen": "2023-09-08T10:56:59.732967-04:00"
},
"https://opentelemetry.io/docs/instrumentation/java/automatic/spring-boot/": {
"StatusCode": 206,
"LastSeen": "2023-12-08T11:19:15.011115+01:00"
},
"https://opentracing.io": {
"StatusCode": 206,
"LastSeen": "2023-06-29T18:41:30.83242-04:00"
Expand Down

0 comments on commit 210e9c6

Please sign in to comment.