Skip to content

fix: bring parent span into ThreadLocals to maintain Observation and span hierarchy parity#6249

Merged
tzolov merged 3 commits into
spring-projects:mainfrom
chemicL:fix-span-hierarchy
Jun 3, 2026
Merged

fix: bring parent span into ThreadLocals to maintain Observation and span hierarchy parity#6249
tzolov merged 3 commits into
spring-projects:mainfrom
chemicL:fix-span-hierarchy

Conversation

@chemicL
Copy link
Copy Markdown
Member

@chemicL chemicL commented Jun 1, 2026

TracingObservationHandler.getParentSpan uses the span present on a Spring MVC thread to be the parent span for Observations for which we provide explicit parentObservation which causes the span hierarchy mismatch the Observation hieararchy.

The reason for the mismatch is this change in Micrometer Tracing: micrometer-metrics/tracing@3bece1e

I'll discuss with the maintainers the path forward, but the interim fix should ensure the proper hierarchy without the need to use automatic context propagation.

chemicL added 3 commits June 2, 2026 00:44
…span hierarchy parity

Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com>
@chemicL chemicL marked this pull request as ready for review June 2, 2026 09:02
@tzolov tzolov added this to the 2.0.0-RC1 milestone Jun 3, 2026
@tzolov tzolov added observability bug Something isn't working streaming labels Jun 3, 2026
@tzolov tzolov merged commit 1dde55d into spring-projects:main Jun 3, 2026
8 of 9 checks passed
tzolov added a commit that referenced this pull request Jun 3, 2026
Apply the same Micrometer Tracing parent scope fix from #6249 to
Anthropic, Bedrock Converse, DeepSeek, Google GenAI, MiniMax, Mistral
AI, and Ollama chat models — briefly opening the parent observation's
scope before observation.start() so span parenting is derived from the
explicit parentObservation rather than the ambient thread scope.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@chemicL chemicL deleted the fix-span-hierarchy branch June 4, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working observability streaming

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants