1
1
---
2
- title : Spring Boot Starter
2
+ title : Spring Boot
3
3
linkTitle : Spring Boot
4
4
weight : 30
5
5
description : Spring Boot instrumentation for OpenTelemetry Java
6
6
# prettier-ignore
7
7
cSpell:ignore : autoconfigurations autoconfigures datasource logback springboot webflux webmvc
8
8
---
9
9
10
+ ## How to instrument Spring Boot with OpenTelemetry
11
+
10
12
The [ OpenTelemetry Java agent] ( .. ) with byte code instrumentation can cover most
11
13
of your needs when instrumenting
12
14
[ Spring Boot] ( https://spring.io/projects/spring-boot ) applications.
@@ -26,15 +28,24 @@ following cases:
26
28
[ Spring Boot starter] :
27
29
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using.build-systems.starters
28
30
29
- The
31
+ The OpenTelemetry Java agent has more automatic instrumentation features than
32
+ the OpenTelemetry starter.
33
+
34
+ You can use
35
+ [ OpenTelemetry instrumentations libraries] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md#libraries--frameworks )
36
+ to complete the automatic instrumentation of the Spring Boot starter.
37
+
38
+ ## OpenTelemetry starter Spring Boot starter
39
+
40
+ ### Compatibility
41
+
42
+ The OpenTelemetry Spring Boot starter works with Spring Boot 2.0 and 3.0, and
43
+ Spring Boot native image applications. The
30
44
[ opentelemetry-java-examples/spring-native] ( https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/spring-native )
31
45
repository contains an example of a Spring Boot Native image application
32
46
instrumented using the OpenTelemetry Spring Boot starter.
33
47
34
- The rest of this page documents the OpenTelemetry starter that works with Spring
35
- Boot 2.0 and 3.0.
36
-
37
- ## Dependency management
48
+ ### Dependency management
38
49
39
50
A Bill of Material
40
51
([ BOM] ( https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms ) )
@@ -115,7 +126,7 @@ with the `io.spring.dependency-management` plugin.
115
126
116
127
{{% /alert %}}
117
128
118
- ### OpenTelemetry Starter dependency
129
+ #### OpenTelemetry Starter dependency
119
130
120
131
Add the dependency given below to enable the OpenTelemetry starter.
121
132
@@ -146,15 +157,15 @@ dependencies {
146
157
147
158
{{% /tab %}} {{< /tabpane>}}
148
159
149
- ### Disable data export
160
+ #### Disable data export
150
161
151
162
{{% config_option name="otel.sdk.disabled" %}}
152
163
153
164
Set the value to ` true ` to disable data export, e.g. for testing purposes.
154
165
155
166
{{% /config_option %}}
156
167
157
- ## OTLP Exporter
168
+ ### OTLP Exporter
158
169
159
170
This package provides autoconfiguration for the
160
171
[ OTLP] ( https://github.com/open-telemetry/opentelemetry-java/tree/main/exporters/otlp )
@@ -166,7 +177,7 @@ As of 2.0.0+ the default protocol is `http/protobuf`. For more details on
166
177
exporter configuration, see
167
178
[ OTLP Exporter Configuration] ( /docs/languages/sdk-configuration/otlp-exporter/ ) .
168
179
169
- ### Enabling/Disabling Exporters
180
+ #### Enabling/Disabling Exporters
170
181
171
182
All exporters can be enabled or disabled as in the
172
183
[ SDK autoconfiguration] ( https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#exporters ) .
@@ -181,13 +192,13 @@ the properties below.
181
192
| OTLP Logs Exporter | ` otel.exporter.otlp.logs.enabled ` | true | ` OtlpHttpLogRecordExporter ` , ` OtlpGrpcLogRecordExporter ` |
182
193
| Logging Exporter | ` otel.exporter.logging.enabled ` | false | ` LoggingSpanExporter ` |
183
194
184
- ## Tracer Properties
195
+ ### Tracer Properties
185
196
186
197
| Feature | Property | Default Value |
187
198
| ------- | --------------------------------- | ------------- |
188
199
| Tracer | ` otel.traces.sampler.probability ` | 1.0 |
189
200
190
- ## Resource Properties
201
+ ### Resource Properties
191
202
192
203
| Feature | Property | Default Value |
193
204
| -------- | ----------------------------------------------------------------------- | ------------- |
@@ -233,7 +244,7 @@ with the OpenTelemetry
233
244
4 . ` spring.application.name ` spring property
234
245
5 . The default value is ` unknown_service:java ` (lowest precedence)
235
246
236
- ## Automatic instrumentation
247
+ ### Automatic instrumentation
237
248
238
249
Autoconfigures OpenTelemetry instrumentation for
239
250
[ spring-web] ( #spring-web-autoconfiguration ) ,
@@ -248,7 +259,7 @@ spring applications.
248
259
| spring-webmvc | ` otel.instrumentation.spring-web.enabled ` | true | ` OncePerRequestFilter ` |
249
260
| spring-webflux | ` otel.instrumentation.spring-webflux.enabled ` | true | ` WebClient ` |
250
261
251
- ### Spring Web Autoconfiguration
262
+ #### Spring Web Autoconfiguration
252
263
253
264
Provides autoconfiguration for the ` RestTemplate ` trace interceptor defined in
254
265
[ opentelemetry-spring-web-3.1] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-web/spring-web-3.1/library ) .
@@ -258,7 +269,7 @@ supported for spring web versions 3.1+. To learn more about the OpenTelemetry
258
269
` RestTemplate ` interceptor, see
259
270
[ opentelemetry-spring-web-3.1] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-web/spring-web-3.1/library ) .
260
271
261
- ### Spring Web MVC Autoconfiguration
272
+ #### Spring Web MVC Autoconfiguration
262
273
263
274
This feature autoconfigures instrumentation for Spring WebMVC controllers by
264
275
adding a
@@ -269,7 +280,7 @@ request. To learn more about the OpenTelemetry Spring WebMVC instrumentation,
269
280
see the
270
281
[ 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 ) .
271
282
272
- ### Spring WebFlux Autoconfiguration
283
+ #### Spring WebFlux Autoconfiguration
273
284
274
285
Provides autoconfigurations for the OpenTelemetry WebClient ExchangeFilter
275
286
defined in
@@ -280,9 +291,9 @@ processor. This feature is supported for spring webflux versions 5.0+. For
280
291
details, see
281
292
[ opentelemetry-spring-webflux-5.3] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/spring/spring-webflux/spring-webflux-5.3/library ) .
282
293
283
- ## Additional Instrumentations
294
+ ### Additional Instrumentations
284
295
285
- ### JDBC Instrumentation
296
+ #### JDBC Instrumentation
286
297
287
298
You have two ways to enable the JDBC instrumentation with the OpenTelemetry
288
299
starter.
@@ -340,7 +351,7 @@ dependencies {
340
351
341
352
{{% /tab %}} {{< /tabpane>}}
342
353
343
- ### Logging Instrumentation
354
+ #### Logging Instrumentation
344
355
345
356
To enable the logging instrumentation for Logback you have to add the
346
357
OpenTelemetry appender in your ` logback.xml ` or ` logback-spring.xml ` file:
389
400
[ Log4j] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/README.md )
390
401
instrumentation libraries.
391
402
392
- ### Instrumentation Annotations
403
+ #### Instrumentation Annotations
393
404
394
405
This feature uses spring-aop to wrap methods annotated with ` @WithSpan ` in a
395
406
span. The arguments to the method can be captured as attributed on the created
@@ -403,7 +414,7 @@ span by annotating the method parameters with `@SpanAttribute`.
403
414
| ----------- | ------------------------------------------ | ------------- | ------------------ |
404
415
| ` @WithSpan ` | ` otel.instrumentation.annotations.enabled ` | true | WithSpan, Aspect |
405
416
406
- #### Dependency
417
+ ##### Dependency
407
418
408
419
{{< tabpane text=true >}} {{% tab header="Maven (` pom.xml ` )" lang=Maven %}}
409
420
@@ -433,7 +444,7 @@ dependencies {
433
444
434
445
{{% /tab %}} {{< /tabpane>}}
435
446
436
- #### Usage
447
+ ##### Usage
437
448
438
449
``` java
439
450
import org.springframework.stereotype.Component ;
@@ -469,12 +480,12 @@ public class TracedClass {
469
480
}
470
481
```
471
482
472
- ### OpenTelemetry instrumentations libraries
483
+ #### OpenTelemetry instrumentations libraries
473
484
474
485
You can configure other instrumentations with
475
486
[ OpenTelemetry instrumentations libraries] ( https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md#libraries--frameworks ) .
476
487
477
- ## Other configurations
488
+ ## Other solutions
478
489
479
490
Instead of using the OpenTelemetry Spring starter, you can use the OpenTelemetry
480
491
autoconfiguration features with an annotation or the Zipkin starter.
0 commit comments