diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInstrumentation.java index 330b2cc63..402b45d93 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInstrumentation.java @@ -12,20 +12,14 @@ import net.bytebuddy.matcher.ElementMatcher; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link DubboInstrumentation} presents that skywalking use class {@link DubboInterceptor} to - * intercept {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}. + * {@link DubboInstrumentation} presents that skywalking intercepts {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)} + * by using {@link DubboInterceptor}. * * @author zhangxin */ public class DubboInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * Enhance class. - */ private static final String ENHANCE_CLASS = "com.alibaba.dubbo.monitor.support.MonitorFilter"; - /** - * Intercept class. - */ private static final String INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.dubbo.DubboInterceptor"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java index 1ec77436d..eea854141 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java @@ -18,10 +18,10 @@ import com.alibaba.dubbo.rpc.RpcContext; /** * {@link DubboInterceptor} define how to enhance class {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}. - * the context data will transport to the provider side by {@link RpcContext#attachments}.but all the version of dubbo framework below 2.8.3 + * the trace context transport to the provider side by {@link RpcContext#attachments}.but all the version of dubbo framework below 2.8.3 * don't support {@link RpcContext#attachments}, we support another way to support it. it is that all request parameters of dubbo service - * need to extend {@link SWBaseBean}, and {@link DubboInterceptor} will inject the serialized context data to the {@link SWBaseBean} bean and - * extract the serialized context data from {@link SWBaseBean}, or the context data will not transport to the provider side. + * need to extend {@link SWBaseBean}, and {@link DubboInterceptor} will inject the trace context data to the {@link SWBaseBean} bean and + * extract the trace context data from {@link SWBaseBean}, or the trace context data will not transport to the provider side. * * @author zhangxin */ @@ -32,12 +32,12 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { /** *

Consumer:

- * The serialized context data will inject the first param that extend {@link SWBaseBean} of dubbo service + * The serialized trace context data will inject the first param that extend {@link SWBaseBean} of dubbo service * if the method {@link BugFixActive#active()} be called. or the serialized context data will inject to the * {@link RpcContext#attachments} for transport to provider side. * *

Provider:

- * The serialized context data will extract from the first param that extend {@link SWBaseBean} of dubbo service + * The serialized trace context data will extract from the first param that extend {@link SWBaseBean} of dubbo service * if the method {@link BugFixActive#active()} be called. or it will extract from {@link RpcContext#attachments}. * current trace segment will ref if the serialize context data is not null. */ @@ -63,44 +63,32 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { ContextCarrier contextCarrier = new ContextCarrier(); ContextManager.INSTANCE.inject(contextCarrier); if (!BugFixActive.isActive()) { - // context.setAttachment("contextData", contextDataStr); - // context的setAttachment方法在重试机制的时候并不会覆盖原有的Attachment - // 参见Dubbo源代码:“com.alibaba.dubbo.rpc.RpcInvocation” - // public void setAttachmentIfAbsent(String key, String value) { - // if (attachments == null) { - // attachments = new HashMap(); - // } - // if (! attachments.containsKey(key)) { - // attachments.put(key, value); - // } - // } - // 在Rest模式中attachment会被抹除,不会传入到服务端 - // Rest模式会将attachment存放到header里面,具体见com.alibaba.dubbo.rpc.protocol.rest.RpcContextFilter //invocation.getAttachments().put("contextData", contextDataStr); + //@see https://github.com/alibaba/dubbo/blob/dubbo-2.5.3/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java#L154-L161 rpcContext.getAttachments().put(ATTACHMENT_NAME_OF_CONTEXT_DATA, contextCarrier.serialize()); } else { - fix283SendNoAttachmentIssue(invocation, contextCarrier.serialize()); + fix283SendNoAttachmentIssue(invocation, contextCarrier); } } else { Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER); - String contextDataStr; + ContextCarrier contextCarrier; if (!BugFixActive.isActive()) { - contextDataStr = rpcContext.getAttachment(ATTACHMENT_NAME_OF_CONTEXT_DATA); + contextCarrier = new ContextCarrier().deserialize(rpcContext.getAttachment(ATTACHMENT_NAME_OF_CONTEXT_DATA)); } else { - contextDataStr = fix283RecvNoAttachmentIssue(invocation); + contextCarrier = fix283RecvNoAttachmentIssue(invocation); } - if (contextDataStr != null && contextDataStr.length() > 0) { - ContextManager.INSTANCE.extract(new ContextCarrier().deserialize(contextDataStr)); + if (contextCarrier != null) { + ContextManager.INSTANCE.extract(contextCarrier); } } } /** - * {@link DubboInterceptor#afterMethod(EnhancedClassInstanceContext, InstanceMethodInvokeContext, Object)} be executed after - * {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}, and it will check {@link Result#getException()} if is null. - * current active span will log the exception and set true to the value of error tag if the {@link Result#getException()} is not null. + * Execute after {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}, + * when dubbo instrumentation is active。Check {@link Result#getException()} , if not NULL, + * log the exception and set tag error=true. */ @Override public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, @@ -121,7 +109,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { } /** - * Active span will log the exception and set current span value of error tag. + * Log the throwable, which occurs in Dubbo RPC service. */ private void dealException(Throwable throwable) { Span span = ContextManager.INSTANCE.activeSpan(); @@ -130,12 +118,11 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { } /** - * Generate operation name. - * the operation name should be like this com.a.eye.skywalking.plugin.test.Test.test(String). + * Format operation name. e.g. com.a.eye.skywalking.plugin.test.Test.test(String) * * @return operation name. */ - private static String generateOperationName(URL requestURL, Invocation invocation) { + private String generateOperationName(URL requestURL, Invocation invocation) { StringBuilder operationName = new StringBuilder(); operationName.append(requestURL.getPath()); operationName.append("." + invocation.getMethodName() + "("); @@ -153,12 +140,12 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { } /** - * Generate request url. - * The request url may be like this dubbo://127.0.0.1:20880/com.a.eye.skywalking.plugin.test.Test.test(String). + * Format request url. + * e.g. dubbo://127.0.0.1:20880/com.a.eye.skywalking.plugin.test.Test.test(String). * * @return request url. */ - private static String generateRequestURL(URL url, Invocation invocation) { + private String generateRequestURL(URL url, Invocation invocation) { StringBuilder requestURL = new StringBuilder(); requestURL.append(url.getProtocol() + "://"); requestURL.append(url.getHost()); @@ -168,28 +155,28 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor { } /** - * Set the serialized context data to the first request param that extend {@link SWBaseBean} of dubbo service. + * Set the trace context. * - * @param contextDataStr serialized context data. + * @param contextCarrier {@link ContextCarrier}. */ - private static void fix283SendNoAttachmentIssue(Invocation invocation, String contextDataStr) { + private void fix283SendNoAttachmentIssue(Invocation invocation, ContextCarrier contextCarrier) { for (Object parameter : invocation.getArguments()) { if (parameter instanceof SWBaseBean) { - ((SWBaseBean) parameter).setContextData(contextDataStr); + ((SWBaseBean) parameter).setTraceContext(contextCarrier.serialize()); return; } } } /** - * Fetch the serialize context data from the first request param that extend {@link SWBaseBean} of dubbo service. + * Fetch the trace context by using {@link Invocation#getArguments()}. * - * @return serialized context data. + * @return trace context data. */ - private static String fix283RecvNoAttachmentIssue(Invocation invocation) { + private ContextCarrier fix283RecvNoAttachmentIssue(Invocation invocation) { for (Object parameter : invocation.getArguments()) { if (parameter instanceof SWBaseBean) { - return ((SWBaseBean) parameter).getContextData(); + return new ContextCarrier().deserialize(((SWBaseBean) parameter).getTraceContext()); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/BugFixActive.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/BugFixActive.java index e09f536b2..937f80279 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/BugFixActive.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/BugFixActive.java @@ -5,7 +5,7 @@ package com.a.eye.skywalking.plugin.dubbox; * The version 2.8.3 of dubbox don't support attachment. so skywalking provided another way * to support the function that transport the serialized context data. The way is that * all parameters of dubbo service need to extend {@link SWBaseBean}, {@link com.a.eye.skywalking.plugin.dubbo.DubboInterceptor} - * fetch the serialized context data by using {@link SWBaseBean#getContextData()}. + * fetch the serialized context data by using {@link SWBaseBean#getTraceContext()}. * * @author zhangxin */ @@ -14,7 +14,7 @@ public final class BugFixActive { private static boolean active = false; /** - * This method should be call first if the dubbo version is below 2.8.3. + * Set active status, before startup dubbo services. */ public static void active() { BugFixActive.active = true; diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/SWBaseBean.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/SWBaseBean.java index eaf6f71fe..6fe4bd57e 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/SWBaseBean.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbox/SWBaseBean.java @@ -4,21 +4,21 @@ import java.io.Serializable; /** * All the request parameter of dubbox service need to extend {@link SWBaseBean} to transport - * the serialized context data to the provider side if the version of dubbox is below 2.8.3. + * the serialized trace context to the provider side if the version of dubbox is below 2.8.3. * * @author zhangxin */ public class SWBaseBean implements Serializable { /** - * Serialized context data. + * Serialized trace context. */ - private String contextData; + private String traceContext; - public String getContextData() { - return contextData; + public String getTraceContext() { + return traceContext; } - public void setContextData(String contextData) { - this.contextData = contextData; + public void setTraceContext(String traceContext) { + this.traceContext = traceContext; } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/skywalking-plugin.def b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/skywalking-plugin.def index 15f3c8eeb..3833d6e87 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/skywalking-plugin.def +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/resources/skywalking-plugin.def @@ -1 +1 @@ -com.a.eye.skywalking.plugin.dubbo.DubboPluginDefine +com.a.eye.skywalking.plugin.dubbo.DubboInstrumentation diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java index 7e6cfb214..d964fb79a 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java @@ -156,7 +156,7 @@ public class DubboInterceptorTest { when(rpcContext.isConsumerSide()).thenReturn(false); when(BugFixActive.isActive()).thenReturn(true); - testParam.setContextData("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1"); + testParam.setTraceContext("302017.1487666919810.624424584.17332.1.1|1|REMOTE_APP|127.0.0.1"); dubboInterceptor.beforeMethod(classInstanceContext, methodInvokeContext, methodInterceptResult); diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/RequestParamForTestBelow283.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/RequestParamForTestBelow283.java index 7c3783b82..3a0173903 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/RequestParamForTestBelow283.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/RequestParamForTestBelow283.java @@ -12,13 +12,13 @@ import static org.junit.Assert.assertThat; public class RequestParamForTestBelow283 extends SWBaseBean { /** - * This method assert that {@link SWBaseBean#getContextData()} if it's not null and context data + * This method assert that {@link SWBaseBean#getTraceContext()} if it's not null and context data * will end with the expect span id. * * @param expectSpanId expect span id */ public void assertSelf(String expectSpanId, String expectHost) { - assertNotNull(getContextData()); - assertThat(getContextData(), endsWith(expectSpanId + "|" + expectHost)); + assertNotNull(getTraceContext()); + assertThat(getTraceContext(), endsWith(expectSpanId + "|" + expectHost)); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java index 335065b19..860be92f4 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java @@ -14,10 +14,11 @@ import org.apache.http.Header; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; /** - * {@link HttpClientExecuteInterceptor} create span and set the serialized context - * data to {@link HttpRequest#setHeader(Header)} by using {@link #HEADER_NAME_OF_CONTEXT_DATA} for the header key. + * {@link HttpClientExecuteInterceptor} transport the trace context by call {@link HttpRequest#setHeader(Header)}, + * The current span tag the {@link Tags#ERROR} if {@link StatusLine#getStatusCode()} is not equals 200. * * @author zhangxin */ @@ -48,7 +49,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc } /** - * Generate request URL by using {@link HttpRequest} and {@link HttpHost} + * Format request URL. * * @return request URL */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java index 5a2a8eb23..2734ca906 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java @@ -13,7 +13,7 @@ import org.apache.http.protocol.HttpContext; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link AbstractHttpClientInstrumentation} presents that skywalking will intercept + * {@link AbstractHttpClientInstrumentation} presents that skywalking intercepts * {@link org.apache.http.impl.client.AbstractHttpClient#doExecute(HttpHost, HttpRequest, HttpContext)} * by using {@link HttpClientInstrumentation#INTERCEPT_CLASS}. * @@ -21,9 +21,6 @@ import static net.bytebuddy.matcher.ElementMatchers.named; */ public class AbstractHttpClientInstrumentation extends HttpClientInstrumentation { - /** - * enhance class. - */ private static final String ENHANCE_CLASS = "org.apache.http.impl.client.AbstractHttpClient"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java index d0fb67722..4670f0b09 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java @@ -13,7 +13,7 @@ import org.apache.http.protocol.HttpContext; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link AbstractHttpClientInstrumentation} presents that skywalking will intercept + * {@link AbstractHttpClientInstrumentation} presents that skywalking intercepts * {@link org.apache.http.impl.client.DefaultRequestDirector#execute(HttpHost, HttpRequest, HttpContext)} * by using {@link HttpClientInstrumentation#INTERCEPT_CLASS}. * diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientInstrumentation.java index 8d7214427..3649e8c1b 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/HttpClientInstrumentation.java @@ -5,16 +5,13 @@ import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint; import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; /** - * {@link HttpClientInstrumentation} present that skywalking will intercept {@link HttpClientInstrumentation#enhanceClassName()} + * {@link HttpClientInstrumentation} present that skywalking intercepts {@link HttpClientInstrumentation#enhanceClassName()} * by using {@link com.a.eye.skywalking.plugin.httpClient.v4.HttpClientExecuteInterceptor} * * @author zhangxin */ public abstract class HttpClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * Intercept class. - */ private static final String INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.httpClient.v4.HttpClientExecuteInterceptor"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java index b0ea0c262..8afbc35ac 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java @@ -13,16 +13,13 @@ import org.apache.http.protocol.HttpContext; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link AbstractHttpClientInstrumentation} presents that skywalking will intercept {@link org.apache.http.impl.client.InternalHttpClient#doExecute(HttpHost, HttpRequest, HttpContext)} + * {@link AbstractHttpClientInstrumentation} presents that skywalking intercepts {@link org.apache.http.impl.client.InternalHttpClient#doExecute(HttpHost, HttpRequest, HttpContext)} * by using {@link HttpClientInstrumentation#INTERCEPT_CLASS}. * * @author zhangxin */ public class InternalHttpClientInstrumentation extends HttpClientInstrumentation { - /** - * Enhance class. - */ private static final String ENHANCE_CLASS = "org.apache.http.impl.client.InternalHttpClient"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java index 95b98d867..dca1b29cf 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java @@ -13,17 +13,14 @@ import org.apache.http.protocol.HttpContext; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link AbstractHttpClientInstrumentation} presents that skywalking will - * intercept {@link org.apache.http.impl.client.MinimalHttpClient#doExecute(HttpHost, HttpRequest, HttpContext)} + * {@link AbstractHttpClientInstrumentation} presents that skywalking + * intercepts {@link org.apache.http.impl.client.MinimalHttpClient#doExecute(HttpHost, HttpRequest, HttpContext)} * by using {@link HttpClientInstrumentation#INTERCEPT_CLASS}. * * @author zhangxin */ public class MinimalHttpClientInstrumentation extends HttpClientInstrumentation { - /** - * Enhance class. - */ private static final String ENHANCE_CLASS = "org.apache.http.impl.client.MinimalHttpClient"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractConnectionURLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractURLParser.java similarity index 78% rename from skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractConnectionURLParser.java rename to skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractURLParser.java index 1ed4fa846..37afca5c4 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractConnectionURLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/AbstractURLParser.java @@ -1,18 +1,10 @@ package com.a.eye.skywalking.plugin.jdbc.connectionurl.parser; -/** - * {@link AbstractConnectionURLParser} is abstract class that the class that parse jdbc url. - * - * @author zhangxin - */ -public abstract class AbstractConnectionURLParser implements ConnectionURLParser { +public abstract class AbstractURLParser implements ConnectionURLParser { - /** - * Connection url - */ protected String url; - public AbstractConnectionURLParser(String url) { + public AbstractURLParser(String url) { this.url = url; } @@ -59,7 +51,4 @@ public abstract class AbstractConnectionURLParser implements ConnectionURLParser return url.substring(indexRange[0], indexRange[1]); } - public String getConnectionURL() { - return this.url; - } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java index 0576492ed..78be61a3f 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java @@ -5,8 +5,7 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; public interface ConnectionURLParser { /** - * The class that extend {@link ConnectionURLParser} spilt - * the database name , the database host(s) from connection url. + * {@link ConnectionURLParser} parses database name and the database host(s) from connection url. * * @return connection info. */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/H2URLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/H2URLParser.java index 81b992501..55b1ae115 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/H2URLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/H2URLParser.java @@ -17,12 +17,9 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; * * @author zhangxin */ -public class H2URLParser extends AbstractConnectionURLParser { +public class H2URLParser extends AbstractURLParser { private static final String LOCALHOST = "localhost"; - /** - * Default port that H2 running with mix mode. - */ private static final int DEFAULT_PORT = 8084; /** * Flag that H2 running with file mode. @@ -32,9 +29,6 @@ public class H2URLParser extends AbstractConnectionURLParser { * Flag that H2 running with memory mode. */ private static final String MEMORY_MODE_FLAG = "mem"; - /** - * H2 data type. - */ private static final String H2_DB_TYPE = "H2"; public H2URLParser(String url) { diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/MysqlURLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/MysqlURLParser.java index 604d115ef..d03336374 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/MysqlURLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/MysqlURLParser.java @@ -3,7 +3,7 @@ package com.a.eye.skywalking.plugin.jdbc.connectionurl.parser; import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; /** - * {@link MysqlURLParser} presents that how to parse mysql connection url. + * {@link MysqlURLParser} parse connection url of mysql. * * The {@link ConnectionInfo#host} be set the string between charset "//" and the first * charset "/" after the charset "//", and {@link ConnectionInfo#databaseName} be set the @@ -12,16 +12,10 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; * * @author zhangxin */ -public class MysqlURLParser extends AbstractConnectionURLParser { +public class MysqlURLParser extends AbstractURLParser { - /** - * Mysql default port. - */ private static final int DEFAULT_PORT = 3306; - /** - * Mysql db type. - */ - private static final String MYSQL_DB_TYPE = "Mysql"; + private static final String DB_TYPE = "Mysql"; public MysqlURLParser(String url) { super(url); @@ -58,13 +52,13 @@ public class MysqlURLParser extends AbstractConnectionURLParser { sb.append(host + ","); } } - return new ConnectionInfo(MYSQL_DB_TYPE, sb.toString(), fetchDatabaseNameFromURL()); + return new ConnectionInfo(DB_TYPE, sb.toString(), fetchDatabaseNameFromURL()); } else { String[] hostAndPort = hostSegment[0].split(":"); if (hostAndPort.length != 1) { - return new ConnectionInfo(MYSQL_DB_TYPE, hostAndPort[0], Integer.valueOf(hostAndPort[1]), fetchDatabaseNameFromURL()); + return new ConnectionInfo(DB_TYPE, hostAndPort[0], Integer.valueOf(hostAndPort[1]), fetchDatabaseNameFromURL()); } else { - return new ConnectionInfo(MYSQL_DB_TYPE, hostAndPort[0], DEFAULT_PORT, fetchDatabaseNameFromURL()); + return new ConnectionInfo(DB_TYPE, hostAndPort[0], DEFAULT_PORT, fetchDatabaseNameFromURL()); } } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/OracleURLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/OracleURLParser.java index eecd7c242..658a975e0 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/OracleURLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/OracleURLParser.java @@ -15,15 +15,9 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; * * @author zhangxin */ -public class OracleURLParser extends AbstractConnectionURLParser { +public class OracleURLParser extends AbstractURLParser { - /** - * Oracle db type. - */ - private static final String ORACLE_DB_TYPE = "Oracle"; - /** - * Oracle default port - */ + private static final String DB_TYPE = "Oracle"; private static final int DEFAULT_PORT = 1521; public OracleURLParser(String url) { @@ -49,9 +43,9 @@ public class OracleURLParser extends AbstractConnectionURLParser { String[] hostSegment = splitDatabaseAddress(host); String databaseName = url.substring(hostRangeIndex[1] + 1); if (hostSegment.length == 1) { - return new ConnectionInfo(ORACLE_DB_TYPE, host, DEFAULT_PORT, databaseName); + return new ConnectionInfo(DB_TYPE, host, DEFAULT_PORT, databaseName); } else { - return new ConnectionInfo(ORACLE_DB_TYPE, hostSegment[0], Integer.valueOf(hostSegment[1]), databaseName); + return new ConnectionInfo(DB_TYPE, hostSegment[0], Integer.valueOf(hostSegment[1]), databaseName); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/URLParser.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/URLParser.java index c6912a8f6..c93fef6c4 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/URLParser.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/connectionurl/parser/URLParser.java @@ -9,13 +9,18 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo; * @author zhangxin */ public class URLParser { + + private static final String MYSQL_JDBC_URL_PREFIX = "jdbc:mysql"; + private static final String ORACLE_JDBC_URL_PREFIX = "jdbc:oracle"; + private static final String H2_JDBC_URL_PREFIX = "jdbc:h2"; + public static ConnectionInfo parser(String url) { ConnectionURLParser parser = null; - if (url.startsWith("jdbc:mysql")) { + if (url.startsWith(MYSQL_JDBC_URL_PREFIX)) { parser = new MysqlURLParser(url); - } else if (url.startsWith("jdbc:oracle")) { + } else if (url.startsWith(ORACLE_JDBC_URL_PREFIX)) { parser = new OracleURLParser(url); - } else if (url.startsWith("jdbc:h2")) { + } else if (url.startsWith(H2_JDBC_URL_PREFIX)) { parser = new H2URLParser(url); } return parser.parse(); diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabaseInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabaseInstrumentation.java index e9d9e4a9b..6ca54fe34 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabaseInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/AbstractDatabaseInstrumentation.java @@ -13,22 +13,14 @@ import java.util.Properties; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * JDBC plugin using {@link JDBCDriverInterceptor} to intercept all the class that extend {@link java.sql.Driver#connect(String, Properties)}, + * JDBC plugin using {@link JDBCDriverInterceptor} to intercept all the class that it has extend {@link java.sql.Driver#connect(String, Properties)}, * and change the return object to {@link com.a.eye.skywalking.plugin.jdbc.SWConnection}, All the method of {@link com.a.eye.skywalking.plugin.jdbc.SWConnection} - * is delete to the real JDBC Driver Connection object. - * It will return {@link com.a.eye.skywalking.plugin.jdbc.SWStatement} when {@link java.sql.Driver} to create {@link java.sql.Statement}, return - * {@link com.a.eye.skywalking.plugin.jdbc.SWPreparedStatement} when {@link java.sql.Driver} to create {@link java.sql.PreparedStatement} and return - * {@link com.a.eye.skywalking.plugin.jdbc.SWCallableStatement} when {@link java.sql.Driver} to create {@link java.sql.CallableStatement}. - * of course, {@link com.a.eye.skywalking.plugin.jdbc.SWStatement}, {@link com.a.eye.skywalking.plugin.jdbc.SWPreparedStatement} and - * {@link com.a.eye.skywalking.plugin.jdbc.SWCallableStatement} are same as {@link SWConnection}. + * is delegate to the real JDBC Driver Connection object. * * @author zhangxin */ public abstract class AbstractDatabaseInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * Intercept class - */ private static final String INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jdbc.define.JDBCDriverInterceptor"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/H2Instrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/H2Instrumentation.java index 6b44b91fd..2e521b0cc 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/H2Instrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/H2Instrumentation.java @@ -1,15 +1,12 @@ package com.a.eye.skywalking.plugin.jdbc.define; /** - * {@link H2Instrumentation} presents that skywalking will intercept {@link org.h2.Driver}. + * {@link H2Instrumentation} presents that skywalking intercepts {@link org.h2.Driver}. * * @author zhangxin */ public class H2Instrumentation extends AbstractDatabaseInstrumentation { - /** - * Class of intercept H2 driver - */ private static final String CLASS_OF_INTERCEPT_H2_DRIVER = "org.h2.Driver"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java index f5439c7b4..41f4c09c1 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/JDBCDriverInterceptor.java @@ -10,8 +10,8 @@ import java.sql.Connection; import java.util.Properties; /** - * {@link JDBCDriverInterceptor} will return {@link SWConnection} when {@link java.sql.Driver#connect(String, Properties)}, - * instead of the instance that extend {@link Connection}. + * {@link JDBCDriverInterceptor} return {@link SWConnection} when {@link java.sql.Driver} to create connection, + * instead of the {@link Connection} instance. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/MysqlInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/MysqlInstrumentation.java index 568088510..b1d4aca8f 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/MysqlInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/MysqlInstrumentation.java @@ -1,7 +1,7 @@ package com.a.eye.skywalking.plugin.jdbc.define; /** - * {@link MysqlInstrumentation} presents that skywalking will intercept {@link com.mysql.jdbc.Driver}. + * {@link MysqlInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/OracleInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/OracleInstrumentation.java index 221f114ec..c19bca7ba 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/OracleInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/define/OracleInstrumentation.java @@ -1,7 +1,7 @@ package com.a.eye.skywalking.plugin.jdbc.define; /** - * {@link OracleInstrumentation} presents that skywalking will intercept the class oracle.jdbc.OracleDriver + * {@link OracleInstrumentation} presents that skywalking intercepts the class oracle.jdbc.OracleDriver * . * * @author zhangxin diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptor.java index 8c2ddecd4..c3e9ea38e 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptor.java @@ -8,12 +8,11 @@ import redis.clients.jedis.HostAndPort; import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_CONN_INFO; import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOST; -import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_HOSTS; import static com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor.KEY_OF_REDIS_PORT; /** - * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch - * from {@link HostAndPort} into {@link EnhancedClassInstanceContext#context}, and each host and port will spilt ;. + * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} record the host and port information from {@link EnhancedClassInstanceContext#context}, + * and each host and port will spilt ;. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java index 1dd91e9ff..aa27d2867 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java @@ -9,8 +9,8 @@ import java.util.Set; import redis.clients.jedis.HostAndPort; /** - * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch - * from {@link HostAndPort} collector into {@link EnhancedClassInstanceContext#context}, and each host and port will spilt ;. + * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} record the host and port information that fetch + * from {@link EnhancedClassInstanceContext#context}, and each host and port will spilt ;. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptor.java index 6a337c79d..34a9f2ecf 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptor.java @@ -7,8 +7,8 @@ import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorIn import redis.clients.jedis.JedisShardInfo; /** - * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch - * from {@link JedisShardInfo} argument into {@link EnhancedClassInstanceContext#context}. + * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host + * and port information from {@link EnhancedClassInstanceContext#context}. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithStringArgInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithStringArgInterceptor.java index e6d2550f2..d7f28d4b8 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithStringArgInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithStringArgInterceptor.java @@ -5,8 +5,8 @@ import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeCont import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor; /** - * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch - * from string argument into {@link EnhancedClassInstanceContext#context}. + * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} record the host + * and port information from {@link EnhancedClassInstanceContext#context}. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithUriArgInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithUriArgInterceptor.java index 5bea6db7e..2640949a6 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithUriArgInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisConstructorWithUriArgInterceptor.java @@ -7,8 +7,8 @@ import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorIn import java.net.URI; /** - * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} will record the host and port information that fetch - * from {@link URI} argument into {@link EnhancedClassInstanceContext#context}. + * {@link JedisClusterConstructorWithHostAndPortArgInterceptor} record the host and port information that fetch + * from {@link EnhancedClassInstanceContext#context}. * * @author zhangxin */ diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterInstrumentation.java index b31c7f487..e60231f9d 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisClusterInstrumentation.java @@ -18,35 +18,19 @@ import static net.bytebuddy.matcher.ElementMatchers.not; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; /** - * {@link JedisClusterInstrumentation} presents that skywalking will intercept all constructors and methods of {@link redis.clients.jedis.JedisCluster}. - * There are two intercept classes to intercept the constructor of {@link redis.clients.jedis.JedisCluster}. + * {@link JedisClusterInstrumentation} presents that skywalking intercepts all constructors and methods of {@link redis.clients.jedis.JedisCluster}. * {@link com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor} intercepts all constructor with argument {@link redis.clients.jedis.HostAndPort} - * and the other constructor will intercept by class {@link JedisClusterConstructorWithListHostAndPortArgInterceptor}. - * {@link JedisMethodInterceptor} will intercept all methods of {@link redis.clients.jedis.JedisCluster} + * and the other constructor intercept by class {@link JedisClusterConstructorWithListHostAndPortArgInterceptor}. + * {@link JedisMethodInterceptor} intercept all methods of {@link redis.clients.jedis.JedisCluster} * * @author zhangxin */ public class JedisClusterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * {@link redis.clients.jedis.HostAndPort} argument type name - */ private static final String ARGUMENT_TYPE_NAME = "redis.clients.jedis.HostAndPort"; - /** - * Enhance class - */ private static final String ENHANCE_CLASS = "redis.clients.jedis.JedisCluster"; - /** - * Class that intercept all constructors with arg. - */ private static final String CONSTRUCTOR_WITH_LIST_HOSTANDPORT_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithListHostAndPortArgInterceptor"; - /** - * Class that intercept all methods. - */ private static final String METHOD_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor"; - /** - * Class that intercept all constructors with {@link redis.clients.jedis.HostAndPort} - */ private static final String CONSTRUCTOR_WITH_HOSTANDPORT_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor"; diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisInstrumentation.java index ee9def3c2..af0401b1d 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/define/JedisInstrumentation.java @@ -4,8 +4,8 @@ import com.a.eye.skywalking.api.plugin.bytebuddy.AllObjectDefaultMethodsMatch; import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint; import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint; import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; -import com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor; import com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor; +import com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor; import com.a.eye.skywalking.plugin.jedis.v2.JedisMethodInterceptor; import net.bytebuddy.description.method.MethodDescription; @@ -20,36 +20,20 @@ import static net.bytebuddy.matcher.ElementMatchers.not; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; /** - * {@link JedisInstrumentation} presents that skywalking will intercept all constructors and methods of {@link redis.clients.jedis.Jedis}. - * There are three intercept classes to intercept the constructor of {@link redis.clients.jedis.Jedis}. + * {@link JedisInstrumentation} presents that skywalking intercept all constructors and methods of {@link redis.clients.jedis.Jedis}. * {@link JedisConstructorWithShardInfoArgInterceptor} intercepts all constructor with argument {@link redis.clients.jedis.HostAndPort} - * ,the constructors with uri will intercept by class {@link JedisConstructorWithUriArgInterceptor} and - * the other constructor will intercept by class {@link JedisConstructorWithShardInfoArgInterceptor}. - * {@link JedisMethodInterceptor} will intercept all methods of {@link redis.clients.jedis.Jedis}. + * ,{@link JedisConstructorWithUriArgInterceptor} intercepts the constructors with uri argument and + * the other constructor intercept by class {@link JedisConstructorWithShardInfoArgInterceptor}. + * {@link JedisMethodInterceptor} intercept all methods of {@link redis.clients.jedis.Jedis}. * * @author zhangxin */ public class JedisInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * {@link redis.clients.jedis.HostAndPort} argument type name - */ private static final String HOST_AND_PROT_ARG_TYPE_NAME = "redis.clients.jedis.HostAndPort"; - /** - * Enhance class - */ private static final String ENHANCE_CLASS = "redis.clients.jedis.Jedis"; - /** - * Class that intercept all constructors with string arg - */ private static final String CONSTRUCTOR_WITH_STRING_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithStringArgInterceptor"; - /** - * Class that intercept all constructors with shard info - */ private static final String CONSTRUCTOR_WITH_SHARD_INFO_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor"; - /** - * Class that intercept all constructors with uri arg - */ private static final String CONSTRUCTOR_WITH_URI_ARG_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/ProviderInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/ProviderInterceptor.java index 72f53665b..e3a7e6a42 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/ProviderInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/ProviderInterceptor.java @@ -26,12 +26,12 @@ import com.weibo.api.motan.rpc.URL; public class ProviderInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor { /** - * The key name of request url that stored in {@link EnhancedClassInstanceContext#context} + * The */ private static final String KEY_NAME_OF_REQUEST_URL = "REQUEST_URL"; /** - * The key name that the serialized context data stored in {@link Request#getAttachments()} + * The {@link Request#getAttachments()} key. It maps to the serialized {@link ContextCarrier}. */ private static final String ATTACHMENT_KEY_OF_CONTEXT_DATA = "contextData"; /** diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ConsumerInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanConsumerInstrumentation.java similarity index 81% rename from skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ConsumerInstrumentation.java rename to skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanConsumerInstrumentation.java index adef99556..d545f4e94 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ConsumerInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanConsumerInstrumentation.java @@ -6,6 +6,7 @@ import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsE import com.a.eye.skywalking.plugin.motan.ConsumerFetchRequestURLInterceptor; import com.a.eye.skywalking.plugin.motan.ConsumerInvokeInterceptor; import com.weibo.api.motan.rpc.Request; +import com.weibo.api.motan.rpc.URL; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -13,25 +14,19 @@ import net.bytebuddy.matcher.ElementMatcher; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link ConsumerInstrumentation} presents that skywalking use {@link ConsumerInvokeInterceptor} - * to intercept {@link com.weibo.api.motan.cluster.support.ClusterSpi#call(Request)} and use + * {@link MotanConsumerInstrumentation} presents that skywalking intercept + * {@link com.weibo.api.motan.cluster.support.ClusterSpi#call(Request)} by using {@link ConsumerInvokeInterceptor} and + * intercept {@link com.weibo.api.motan.cluster.support.ClusterSpi#setUrl(URL)} by using * {@link ConsumerFetchRequestURLInterceptor} to intercept{@link ConsumerFetchRequestURLInterceptor}. * * @author zhangxin */ -public class ConsumerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class MotanConsumerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - /** - * Enhance class. - */ private static final String ENHANCE_CLASS = "com.weibo.api.motan.cluster.support.ClusterSpi"; - /** - * Class that intercept for fetch request url. - */ + private static final String FETCH_REQUEST_URL_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.motan.ConsumerFetchRequestURLInterceptor"; - /** - * Class that intercept {@link com.weibo.api.motan.cluster.support.ClusterSpi#call(Request)}. - */ + private static final String INVOKE_INTERCEPT_CLASS = "com.a.eye.skywalking.plugin.motan.ConsumerInvokeInterceptor"; @Override diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ProviderInstrumentation.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanProviderInstrumentation.java similarity index 93% rename from skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ProviderInstrumentation.java rename to skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanProviderInstrumentation.java index 5a629023b..5e47bbb99 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/ProviderInstrumentation.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/define/MotanProviderInstrumentation.java @@ -12,14 +12,14 @@ import static net.bytebuddy.matcher.ElementMatchers.any; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link ProviderInstrumentation} presents that skywalking will use + * {@link MotanProviderInstrumentation} presents that skywalking will use * {@link com.a.eye.skywalking.plugin.motan.ProviderInterceptor} to intercept * all constructor of {@link com.weibo.api.motan.rpc.AbstractProvider} and * {@link com.weibo.api.motan.rpc.AbstractProvider#call(Request)}. * * @author zhangxin */ -public class ProviderInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class MotanProviderInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { /** * Enhance class. diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/resources/skywalking-plugin.def b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/resources/skywalking-plugin.def index f223bc720..1098cb7c2 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/resources/skywalking-plugin.def +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/resources/skywalking-plugin.def @@ -1,2 +1,2 @@ -com.a.eye.skywalking.plugin.motan.define.ConsumerInstrumentation -com.a.eye.skywalking.plugin.motan.define.ProviderInstrumentation +com.a.eye.skywalking.plugin.motan.define.MotanConsumerInstrumentation +com.a.eye.skywalking.plugin.motan.define.MotanProviderInstrumentation diff --git a/skywalking-sniffer/skywalking-sdk-plugin/pom.xml b/skywalking-sniffer/skywalking-sdk-plugin/pom.xml index e1a61be3c..1ec3033ac 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/pom.xml +++ b/skywalking-sniffer/skywalking-sdk-plugin/pom.xml @@ -31,12 +31,12 @@ com.a.eye skywalking-api - 3.0-2017 + ${project.version} com.a.eye skywalking-sniffer-mock - 3.0-2017 + ${project.version} test