[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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
I mean to put a flag in ContextManager.getRuntimeContext() when firstly creates span. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Okay, also, is it feasible to save a flag in the runtime context to track whether a span has already been created? |
Beta Was this translation helpful? Give feedback.
-
Usually no, unless there is no other proper way. |
Beta Was this translation helpful? Give feedback.
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
Beta Was this translation helpful? Give feedback.
All reactions