Hello,
I originally posted this issue in the micrometer tracing, but since it seems to be related to multiple dependencies, I moved it here.
I found a problem with duplicate TraceIds on repeated requests when using the @NewSpan annotation, with datasource-micrometer auto-configured.
This is a project that can reproduce this issue. https://github.com/0tak2/simpletodo-otel
Reproduction conditions
- Micrometer Tracing is Auto Configured with Spring Boot Actuator
- Tracing is exported to OpenTelemetry Collector
- using @NewSpan with
micrometer.observations.annotations.enabledset totruein Spring Boot Properties- https://github.com/0tak2/simpletodo-otel/blob/main/src/main/java/kr/pe/otak2/study/otel/otelmanualinst/controller/ToDoController.java#L28
- https://github.com/0tak2/simpletodo-otel/blob/main/src/main/java/kr/pe/otak2/study/otel/otelmanualinst/controller/ToDoController.java#L39
- https://github.com/0tak2/simpletodo-otel/blob/main/src/main/java/kr/pe/otak2/study/otel/otelmanualinst/service/TodoServiceImpl.java#L28
- https://github.com/0tak2/simpletodo-otel/blob/main/src/main/java/kr/pe/otak2/study/otel/otelmanualinst/service/TodoServiceImpl.java#L48
* The versions of the related libraries are as follows
Reproduction Scenario
- Repeat the data add request (POST /todo) and retrieve request (GET /todo) with HTTP test tool (see: https://github.com/0tak2/simpletodo-otel/blob/main/http/todo.http)
- Or, open the web client (/client/index.html) in multiple tabs and repeat adding Todo data. (Each time a CUD operation is performed, a websocket event is published to make clients retrieve new data.)
Additional notes
- The issue is only reproduced when both of the following conditions are met
- Set
micrometer.observations.annotations.enabledtotrueand use @NewSpan - include the dependency
net.ttddyy.observation:datasource-micrometer-spring-boot.
- Set
I would appreciate it if you could take a look at this issue, or if you have any tips on debugging the part of the code where the TraceId is specified, I will try to analyse the code.
Comment From: mhalbritter
Hello,
I don't think that the issue is in Spring Boot. Spring Boot only provides auto-configuration for the tracing system. If this only happens when @NewSpan is used and net.ttddyy.observation:datasource-micrometer-spring-boot is used, I suspect the bug is in one of those components. Maybe it's even in the websocket code, I can't tell, as there's a lot going on in this project.
I'd suggest trying to reduce the complexity by ripping parts out (is the websocket code needed? Does it work without @NewSpan? Does it work without the datasource instrumentation?) and then re-opening the micrometer-tracing issue or creating an issue in the affected component.
The class which manages the span is io.micrometer.tracing.otel.bridge.OtelTracer.
If there's really a bug in Spring Boot, please don't hesitate to comment here and I'll reopen this issue.
Comment From: 0tak2
I am sorry for my confusion, and thank you for taking a closer look at this issue nonetheless. I'll try to refine the issue and raise it again in micrometer tracing or datasource or another repository.