-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThreadLocals not cleared with Hooks.enableAutomaticContextPropagation()
, same TraceId for every request
#3584
Comments
Please try with the latest snapshot of micrometer-tracing 1.1.6. I have reasons to believe what you are seeing is a regression, described in micrometer-metrics/tracing#356. If you use 1.1.4 the issue should also be gone. LMK. |
With 1.1.4, the issue is gone, but not with 1.1.6-SNAPSHOT. Updated pom<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo1</name>
<description>demo1</description>
<properties>
<java.version>17</java.version>
<!-- Works -->
<!-- <micrometer-tracing.version>1.1.4</micrometer-tracing.version>-->
<!-- Doesn't Work -->
<micrometer-tracing.version>1.1.6-SNAPSHOT</micrometer-tracing.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
</project> I guess this means that this is actually a bug within micrometer-tracing. Can you transfer this issue or should I open a dedicated issue over there? |
Thanks for confirming. Please try 1.2.0-SNAPSHOT. I am guessing @marcingrzejszczak merged micrometer-metrics/tracing@89b4e94 into main branch, which is the base for 1.2.0 line instead of 1.1.x which is the base for 1.1.6-SNAPSHOT. Feel free to open an issue in the tracing repo in the meantime. |
1.2.0-SNAPSHOT did not fix this either, I have opened micrometer-metrics/tracing#363. |
Expected Behavior
Automatic context propagation (enabled with
Hooks.enableAutomaticContextPropagation()
) should clear the thread-locals afterwards.Actual Behavior
After the first request handled by a particular thread, every subsequent request handled by that thread will reuse the same traceId.
Steps to Reproduce
Demo project: reproducer.zip
Run it and issue a few requests to
localhost:8080
, the output will be something like this:With
reactor.netty.ioWorkerCount=1
:With
reactor.netty.ioWorkerCount=3
:As we can see, requests handled by a thread will always reuse the same traceId, indicating that thread-locals popuplated by automatic context propagation are not cleared/reset after each request.
Without automatic context propagation,
tracer.currentSpan()
returnsnull
.Possible Solution
Your Environment
netty
, ...):java -version
):Related Issues
#3375
The text was updated successfully, but these errors were encountered: