skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Bug] SkyWalking Java agent okhttp plugin Wrong url used to create span

Open PepoRobert opened this issue 4 years ago • 2 comments

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.

image

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

PepoRobert avatar Mar 17 '22 07:03 PepoRobert

Assigned to @PepoRobert as Yes I am willing to submit a PR! checked.

wu-sheng avatar Mar 17 '22 07:03 wu-sheng

No update for 2 weeks.

wu-sheng avatar Apr 01 '22 06:04 wu-sheng