提交 ec857190 编写于 作者: Z zhangxin

update the comment to improve the comment readable

上级 9654b01c
......@@ -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
......
......@@ -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 {
/**
* <h2>Consumer:</h2>
* 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.
*
* <h2>Provider:</h2>
* 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<String, String>();
// }
// 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 <code>com.a.eye.skywalking.plugin.test.Test.test(String)</code>.
* 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 <code>dubbo://127.0.0.1:20880/com.a.eye.skywalking.plugin.test.Test.test(String)</code>.
* 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());
}
}
......
......@@ -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;
......
......@@ -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;
}
}
com.a.eye.skywalking.plugin.dubbo.DubboPluginDefine
com.a.eye.skywalking.plugin.dubbo.DubboInstrumentation
......@@ -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);
......
......@@ -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));
}
}
......@@ -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
*/
......
......@@ -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
......
......@@ -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}.
*
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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;
}
}
......@@ -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.
*/
......
......@@ -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) {
......
......@@ -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());
}
}
}
......
......@@ -15,15 +15,9 @@ import com.a.eye.skywalking.plugin.jdbc.ConnectionInfo;
*
* @author zhangxin
*/
public class OracleURLParser extends AbstractConnectionURLParser {
/**
* Oracle db type.
*/
private static final String ORACLE_DB_TYPE = "Oracle";
/**
* Oracle default port
*/
public class OracleURLParser extends AbstractURLParser {
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);
}
}
......
......@@ -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();
......
......@@ -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
......
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
......
......@@ -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
*/
......
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
*/
......
package com.a.eye.skywalking.plugin.jdbc.define;
/**
* {@link OracleInstrumentation} presents that skywalking will intercept the class <code>oracle.jdbc.OracleDriver
* {@link OracleInstrumentation} presents that skywalking intercepts the class <code>oracle.jdbc.OracleDriver
* </code>.
*
* @author zhangxin
......
......@@ -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
*/
......
......@@ -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
*/
......
......@@ -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
*/
......
......@@ -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
*/
......
......@@ -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
*/
......
......@@ -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";
......
......@@ -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
......
......@@ -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";
/**
......
......@@ -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
......
......@@ -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.
......
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
......@@ -31,12 +31,12 @@
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-api</artifactId>
<version>3.0-2017</version>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-sniffer-mock</artifactId>
<version>3.0-2017</version>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册