Skip to content

Commit

Permalink
Merge pull request #704 from ascrutae/fix/jettyclient-issue
Browse files Browse the repository at this point in the history
[Agent] Unsupport the async function of jetty client plugin
  • Loading branch information
wu-sheng committed Dec 25, 2017
2 parents 5e40b8e + 65693c3 commit 6b288b3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 507 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
*
*/


package org.apache.skywalking.apm.plugin.jetty.v9.client;

import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.eclipse.jetty.client.HttpRequest;
import org.eclipse.jetty.http.HttpFields;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.eclipse.jetty.http.HttpMethod;

public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInterceptor {

Expand All @@ -42,7 +42,19 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(request.getURI().getPath(), contextCarrier, request.getHost() + ":" + request.getPort());
span.setComponent(ComponentsDefine.JETTY_CLIENT);
Tags.HTTP.METHOD.set(span, "GET");
HttpMethod httpMethod = HttpMethod.GET;

/**
* The method is null if the client using GET method.
*
* @see org.eclipse.jetty.client.HttpRequest#GET(String uri)
* @see org.eclipse.jetty.client.HttpRequest( org.eclipse.jetty.client.HttpClient client, long conversation, java.net.URI uri)
*/
if (request.getMethod() != null) {
httpMethod = request.getMethod();
}

Tags.HTTP.METHOD.set(span, httpMethod.asString());
Tags.URL.set(span, request.getURI().toString());
SpanLayer.asHttp(span);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@

import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;

/**
* {@link HttpRequestInstrumentation} enhance the <code>send</code> method without argument in
Expand All @@ -43,8 +42,7 @@ public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePlugi

private static final String ENHANCE_CLASS = "org.eclipse.jetty.client.HttpRequest";
private static final String ENHANCE_CLASS_NAME = "send";
public static final String ASYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.client.AsyncHttpRequestSendInterceptor";
public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.client.SyncHttpRequestSendInterceptor";
public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.v9.client.SyncHttpRequestSendInterceptor";

@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
Expand All @@ -62,20 +60,6 @@ public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePlugi
return SYNC_SEND_INTERCEPTOR;
}

@Override public boolean isOverrideArgs() {
return false;
}
},
new InstanceMethodsInterceptPoint() {
//async call interceptor point
@Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(ENHANCE_CLASS_NAME).and(takesArgumentWithType(0, "org.eclipse.jetty.client.api.Response$CompleteListener"));
}

@Override public String getMethodsInterceptor() {
return ASYNC_SEND_INTERCEPTOR;
}

@Override public boolean isOverrideArgs() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
jetty-client-9.x=org.apache.skywalking.apm.plugin.jetty.v9.client.define.CompleteListenerInstrumentation
jetty-client-9.x=org.apache.skywalking.apm.plugin.jetty.v9.client.define.HttpRequestInstrumentation

0 comments on commit 6b288b3

Please sign in to comment.