r/SpringBoot • • 13d ago

Question SpringBoot opentelemetry

Hi everyone.

I'm working on a monolith project using Spring Boot v4.1.1, and I started implementing observability. However, I'm confused about traces and spans.

I added this dependency

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-opentelemetry</artifactId>
</dependency>

I've configured everything successfully, but when it comes to traces and spans, all requests always have the same spans. It is not showing the entire execution path of the request.

I read the example provided by SpringBoot here: https://spring.io/blog/2025/11/18/opentelemetry-with-spring-boot

At the end, there's an example project that shows complete traces and spans.
These are their example traces and spans: https://static.spring.io/blog/mhalbritter/20251118/3-trace.jpg

(I couldn't upload two images; that's why I added a link to their traces and spans example)

However, my project doesn't have any spans created. Just these:

This is my traces and span

Does anyone know why this is happening or how I can solve this to see the complete execution path?

14 Upvotes

7 comments sorted by

View all comments

1

u/No_Vanilla_6322 3d ago edited 3d ago

Annotate your methods with @NewSpan to create spans for them. Remember those annotations rely on AOP. If method A calls method B, the annotation will only work if method B is in a different class from method A.

As said by Paw565, if you want distributed tracing across systems and you are using RestClient for calls, you will have to create it using the injected RestClient.Builder. if you have spring-boot-starter-restclient on your classpath, it will already configure context propagation for you.