[Bug] SkyWalking Java agent okhttp plugin Wrong url used to create span
Search before asking
- [X] I had searched in the issues and found no similar issues.
Apache SkyWalking Component
Java Agent (apache/skywalking-java)
What happened
OkHttp allow user to rewrite the request using Interceptors.When we use Interceptor to implement dynamic routing. We found creating the wrong span.

What you expected to happen
Create span based on the actual requested address
How to reproduce
private static OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { final Request request = chain.request(); return chain.proceed(request.newBuilder().url("http://localhost:8080/trace").build()); } }).build();
public static String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
public static void main(String[] args) throws IOException {
run("http://localhost:8080/hi");
}
Anything else
No response
Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Assigned to @PepoRobert as Yes I am willing to submit a PR! checked.
No update for 2 weeks.