Repository navigation
[Bug] apm-jdk-http-plugin leads to duplicated traceid #13247
Replies: 7 comments
|
This is a common edge case. The retry mechanism is always bringing new challenges. What do you propose as you clicked |
I think we can try to track whether the current thread has already created a span (in apm-jdk-http-plugin scope). If it has already been created, we will not create a new one. This way, when the writeRequest method is called again (e.g., during retries), duplicate spans won't be created for the same operation. |
|
Do you mean to check the current span? How do you verify whether a span is created? I am not sure. In theory, every retry should create a span, so, you should consider to closing the previous span and recreating works. |
I mean to put a flag in ContextManager.getRuntimeContext() when firstly creates span. |
From the user perspective, the RPC happened multiple times, you should have those. And metrics of requesting should be more than server side traffic, which indicates the retry happens. |
Okay, also, is it feasible to save a flag in the runtime context to track whether a span has already been created? |
|
Usually no, unless there is no other proper way. |

Uh oh!
There was an error while loading. Please reload this page.
Search before asking
Apache SkyWalking Component
Java Agent (apache/skywalking-java)
What happened
In apm-jdk-http-plugin, it creates span brefore 'writeRequests' method in sun.net.www.http.HttpClient and stop span after 'parseHTTP' method. However, within the writeRequest method, if a request fails, the writeRequest method might be called again for retry purposes.
What you expected to happen
How to reproduce
public static InputStream getInputStream(String urlPath) {
InputStream inputStream = null;
HttpURLConnection httpURLConnection = null;
try {
URL url = new URL(urlPath);
httpURLConnection = (HttpURLConnection) url.openConnection();
To reproduce the issue by simulating network packet loss, we can use tools like tc (Traffic Control) on Linux and run the code above.
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Code of Conduct
All reactions