Skip to content

Spring Boot Tracing in Integration Tests

Paulo Gomes da Cruz Junior edited this page Aug 25, 2026 · 1 revision

Spring Boot Tracing in Integration Tests

The gotcha

In Spring Boot 4.1, @SpringBootTest deliberately does not configure tracing components that report data. A test context can therefore provide a no-op Tracer, an empty propagator set, and SimpleObservationRegistry even when the application has the expected Micrometer Tracing and Brave runtime dependencies.

This is easy to misdiagnose as a missing dependency. A dependency tree cannot distinguish an absent runtime module from the test framework's deliberate no-op behavior.

Fix

Add @AutoConfigureTracing to an integration test that needs reporting tracing components:

import org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing;

@AutoConfigureTracing

For Spring Boot 4.1, the annotation is provided by the test-scope artifact org.springframework.boot:spring-boot-micrometer-tracing-test:4.1.0. In this project the artifact was not available transitively, so it was added directly in test scope. It is not a production dependency.

Diagnostic order

When an integration test sees a no-op span or fails to propagate headers:

  1. Check the test's tracer implementation, propagator beans, and observation registry.
  2. Read the Spring Boot test documentation before treating dependency output as causal evidence.
  3. Confirm the test uses the intended context rather than a narrower test slice.
  4. Add @AutoConfigureTracing when the test needs reporting tracing components.

The application should still be checked for actual dependency and configuration errors, but those checks do not replace the framework-specific test configuration check.

Citations

[1] Using Tracing in Spring Boot tests

[2] Spring Boot Actuator tracing

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally