提交 be18fe22 编写于 作者: wu-sheng's avatar wu-sheng

Merge branch 'feature/3.0' into feature/collector

* feature/3.0:
  Add mock-module test cases.
  fix compile issues
  Add Tomcat span, and singleTrace mock.
  Give a sample code of the first Mock trace.
  Add skywalking-sniffer-mock module. For testing sdk-plugin and collector(not merged yet) modules.
  Big refactor. Rename the api-module root package name .
  remove blank line.
  Refactor tags.
  Take Adrian Cole ’s advice, remove http prefix of tag. Maybe still need some improvements.
  Refactor code.
  add delegate method
package com.a.eye.skywalking.health.report;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import java.util.Arrays;
import java.util.Map;
......
package com.a.eye.skywalking.logging.impl.log4j2;
package com.a.eye.skywalking.api.logging.impl.log4j2;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.ILog;
import org.apache.logging.log4j.Logger;
/**
......
package com.a.eye.skywalking.logging.impl.log4j2;
package com.a.eye.skywalking.api.logging.impl.log4j2;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogResolver;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogResolver;
import org.apache.logging.log4j.LogManager;
/**
......
......@@ -13,69 +13,88 @@ public final class Tags {
}
/**
* HTTP_URL records the url of the incoming request.
* URL records the url of the incoming request.
*/
public static final StringTag HTTP_URL = new StringTag("http.url");
public static final StringTag URL = new StringTag("url");
/**
* HTTP_STATUS records the http status code of the response.
* STATUS_CODE records the http status code of the response.
*/
public static final IntTag HTTP_STATUS = new IntTag("http.status_code");
public static final IntTag STATUS_CODE = new IntTag("status_code");
/**
* SPAN_KIND represents the kind of span.
* e.g. db=database, rpc=Remote Procedure Call, nosql=something like redis/memcache
* SPAN_KIND hints at the relationship between spans, e.g. client/server.
*/
public static final class SPAN_KIND{
private static StringTag SPAN_KIND_TAG = new StringTag("span.kind");
public static final StringTag SPAN_KIND = new StringTag("span.kind");
private static final String DB_KIND = "db";
private static final String RPC_KIND = "rpc";
private static final String NOSQL_KIND = "nosql";
private static final String HTTP_KIND = "http";
/**
* A constant for setting the span kind to indicate that it represents a server span.
*/
public static final String SPAN_KIND_SERVER = "server";
/**
* A constant for setting the span kind to indicate that it represents a client span.
*/
public static final String SPAN_KIND_CLIENT = "client";
/**
* SPAN_LAYER represents the kind of span.
*
* e.g.
* db=database;
* rpc=Remote Procedure Call Framework, like motan, thift;
* nosql=something like redis/memcache
*/
public static final class SPAN_LAYER {
private static StringTag SPAN_LAYER_TAG = new StringTag("span.layer");
private static final String RDB_LAYER = "rdb";
private static final String RPC_FRAMEWORK_LAYER = "rpc";
private static final String NOSQL_LAYER = "nosql";
private static final String HTTP_LAYER = "http";
public static void asDBAccess(Span span){
SPAN_KIND_TAG.set(span, DB_KIND);
public static void asRDB(Span span) {
SPAN_LAYER_TAG.set(span, RDB_LAYER);
}
public static void asRPC(Span span){
SPAN_KIND_TAG.set(span, RPC_KIND);
public static void asRPCFramework(Span span) {
SPAN_LAYER_TAG.set(span, RPC_FRAMEWORK_LAYER);
}
public static void asNoSQL(Span span){
SPAN_KIND_TAG.set(span, NOSQL_KIND);
public static void asNoSQL(Span span) {
SPAN_LAYER_TAG.set(span, NOSQL_LAYER);
}
public static void asHttp(Span span){
SPAN_KIND_TAG.set(span, HTTP_KIND);
public static void asHttp(Span span) {
SPAN_LAYER_TAG.set(span, HTTP_LAYER);
}
public static String get(Span span){
return SPAN_KIND_TAG.get(span);
public static String get(Span span) {
return SPAN_LAYER_TAG.get(span);
}
public static boolean isDBAccess(Span span){
return DB_KIND.equals(get(span));
public static boolean isRDB(Span span) {
return RDB_LAYER.equals(get(span));
}
public static boolean isRPC(Span span){
return RPC_KIND.equals(get(span));
public static boolean isRPCFramework(Span span) {
return RPC_FRAMEWORK_LAYER.equals(get(span));
}
public static boolean isNoSQL(Span span){
return NOSQL_KIND.equals(get(span));
public static boolean isNoSQL(Span span) {
return NOSQL_LAYER.equals(get(span));
}
public static boolean isHttp(Span span){
return HTTP_KIND.equals(get(span));
public static boolean isHttp(Span span) {
return HTTP_LAYER.equals(get(span));
}
}
/**
* COMPONENT is a low-cardinality identifier of the module, library, or package that is instrumented.
* Like dubbo/dubbox/motan
* COMPONENT is a low-cardinality identifier of the module, library, or package that is instrumented.
* Like dubbo/dubbox/motan
*/
public static final StringTag COMPONENT = new StringTag("component");
public static final StringTag COMPONENT = new StringTag("component");
/**
* ERROR indicates whether a Span ended in an error state.
......@@ -83,17 +102,17 @@ public final class Tags {
public static final BooleanTag ERROR = new BooleanTag("error");
/**
* PEER_HOST_IPV4 records IPv4 host address of the peer.
* PEER_HOST records host address of the peer, maybe IPV4, IPV6 or hostname.
*/
public static final IntTag PEER_HOST_IPV4 = new IntTag("peer.ipv4");
public static final StringTag PEER_HOST = new StringTag("peer.host");
/**
* DB_URL records the url of the database access.
* DB_URL records the url of the database access.
*/
public static final StringTag DB_URL = new StringTag("db.url");
/**
* DB_SQL records the sql statement of the database access.
* DB_STATEMENT records the sql statement of the database access.
*/
public static final StringTag DB_SQL = new StringTag("db.statement");
public static final StringTag DB_STATEMENT = new StringTag("db.statement");
}
package com.a.eye.skywalking.trace;
import com.a.eye.skywalking.trace.tag.Tags;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
......@@ -38,52 +37,22 @@ public class SpanTestCase {
@Test
public void testSetTag() {
Span span1 = new Span(0, "serviceA");
Tags.SPAN_KIND.asHttp(span1);
Tags.SPAN_LAYER.asHttp(span1);
Tags.COMPONENT.set(span1, "Spring");
Tags.PEER_HOST_IPV4.set(span1, ipToInt("127.0.0.1"));
Tags.PEER_HOST.set(span1, "127.0.0.1");
Tags.ERROR.set(span1, true);
Tags.HTTP_STATUS.set(span1, 302);
Tags.HTTP_URL.set(span1, "http://127.0.0.1/serviceA");
Tags.STATUS_CODE.set(span1, 302);
Tags.URL.set(span1, "http://127.0.0.1/serviceA");
Tags.DB_URL.set(span1, "jdbc:127.0.0.1:user");
Tags.DB_SQL.set(span1, "select * from users");
Tags.DB_STATEMENT.set(span1, "select * from users");
Map<String, Object> tags = span1.getTags();
Assert.assertEquals(8, tags.size());
Assert.assertTrue(Tags.SPAN_KIND.isHttp(span1));
Assert.assertEquals("127.0.0.1", intToIp(Tags.PEER_HOST_IPV4.get(span1)));
Assert.assertTrue(Tags.SPAN_LAYER.isHttp(span1));
Assert.assertEquals("127.0.0.1", Tags.PEER_HOST.get(span1));
Assert.assertTrue(Tags.ERROR.get(span1));
}
private int ipToInt(String ipAddress) {
int result = 0;
String[] ipAddressInArray = ipAddress.split("\\.");
for (int i = 3; i >= 0; i--) {
int ip = Integer.parseInt(ipAddressInArray[3 - i]);
//left shifting 24,16,8,0 and bitwise OR
//1. 192 << 24
//1. 168 << 16
//1. 1 << 8
//1. 2 << 0
result |= ip << (i * 8);
}
return result;
}
private static String intToIp(int longIp) {
StringBuffer sb = new StringBuffer("");
sb.append(String.valueOf((longIp >>> 24)));
sb.append(".");
sb.append(String.valueOf((longIp & 0x00FFFFFF) >>> 16));
sb.append(".");
sb.append(String.valueOf((longIp & 0x0000FFFF) >>> 8));
sb.append(".");
sb.append(String.valueOf((longIp & 0x000000FF)));
return sb.toString();
}
@Test
public void testLogException(){
Span span1 = new Span(0, "serviceA");
......
package com.a.eye.skywalking.util;
package com.a.eye.skywalking.api.util;
public final class StringUtil {
public static boolean isEmpty(String str) {
......
......@@ -17,6 +17,7 @@
<module>skywalking-api</module>
<module>skywalking-sdk-plugin</module>
<module>skywalking-toolkit-activation</module>
<module>skywalking-sniffer-mock</module>
</modules>
<properties>
......
......@@ -2,13 +2,13 @@ package com.a.eye.skywalking.agent;
import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.conf.SnifferConfigInitializer;
import com.a.eye.skywalking.api.conf.SnifferConfigInitializer;
import com.a.eye.skywalking.logging.EasyLogResolver;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.plugin.PluginBootstrap;
import com.a.eye.skywalking.plugin.PluginDefineCategory;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.PluginBootstrap;
import com.a.eye.skywalking.api.plugin.PluginDefineCategory;
import com.a.eye.skywalking.plugin.PluginException;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.NamedElement;
......
package com.a.eye.skywalking.agent.junction;
import com.a.eye.skywalking.plugin.PluginDefineCategory;
import com.a.eye.skywalking.api.plugin.PluginDefineCategory;
import net.bytebuddy.description.NamedElement;
/**
......
......@@ -51,26 +51,6 @@
<artifactId>disruptor</artifactId>
<version>3.3.6</version>
</dependency>
<!-- test dependencies section -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.a.eye.skywalking.conf;
package com.a.eye.skywalking.api.conf;
import com.a.eye.skywalking.util.TraceIdGenerator;
import com.a.eye.skywalking.api.util.TraceIdGenerator;
public class Constants {
/**
......
package com.a.eye.skywalking.conf;
package com.a.eye.skywalking.api.conf;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.util.ConfigInitializer;
import com.a.eye.skywalking.util.StringUtil;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.util.ConfigInitializer;
import com.a.eye.skywalking.api.util.StringUtil;
import java.io.File;
import java.io.FileInputStream;
......
package com.a.eye.skywalking.context;
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.trace.TraceSegmentRef;
import com.a.eye.skywalking.util.StringUtil;
import com.a.eye.skywalking.api.util.StringUtil;
import java.io.Serializable;
/**
......
package com.a.eye.skywalking.context;
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.queue.TraceSegmentProcessQueue;
import com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
......@@ -39,6 +39,20 @@ public enum ContextManager implements TracerContextListener {
return segment;
}
/**
* @see {@link TracerContext#inject(ContextCarrier)}
*/
public void inject(ContextCarrier carrier) {
get().inject(carrier);
}
/**
*@see {@link TracerContext#extract(ContextCarrier)}
*/
public void extract(ContextCarrier carrier) {
get().extract(carrier);
}
public Span createSpan(String operationName) {
return get().createSpan(operationName);
}
......
package com.a.eye.skywalking.context;
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
import com.a.eye.skywalking.util.TraceIdGenerator;
import java.lang.reflect.Executable;
import com.a.eye.skywalking.api.util.TraceIdGenerator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
......@@ -173,7 +171,7 @@ public final class TracerContext {
/**
* Clear the given {@link TracerContextListener}
*/
static synchronized void remove(TracerContextListener listener){
public static synchronized void remove(TracerContextListener listener){
listeners.remove(listener);
}
}
......
package com.a.eye.skywalking.logging;
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogResolver;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogResolver;
/**
* Created by wusheng on 2016/11/26.
......
package com.a.eye.skywalking.logging;
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.util.LoggingUtil;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.util.LoggingUtil;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import static com.a.eye.skywalking.logging.LogLevel.*;
import static com.a.eye.skywalking.api.logging.LogLevel.*;
/**
* Created by xin on 16-6-23.
*/
public class EasyLogger implements com.a.eye.skywalking.logging.api.ILog {
public class EasyLogger implements ILog {
private Class toBeLoggerClass;
......
package com.a.eye.skywalking.logging;
package com.a.eye.skywalking.api.logging;
public interface IWriter {
void write(String message);
......
package com.a.eye.skywalking.logging;
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.util.LoggingUtil;
import com.a.eye.skywalking.api.conf.Config;
import com.a.eye.skywalking.api.util.LoggingUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
......
package com.a.eye.skywalking.logging;
package com.a.eye.skywalking.api.logging;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.api.conf.Config;
public class WriterFactory {
private WriterFactory(){
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.util.StringUtil;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
import com.a.eye.skywalking.api.util.StringUtil;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.pool.TypePool.Resolution;
......@@ -10,7 +11,7 @@ import net.bytebuddy.pool.TypePool.Resolution;
* Basic abstract class of all sky-walking auto-instrumentation plugins.
* <p>
* It provides the outline of enhancing the target class.
* If you want to know more about enhancing, you should go to see {@link com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine}
* If you want to know more about enhancing, you should go to see {@link ClassEnhancePluginDefine}
*/
public abstract class AbstractClassEnhancePluginDefine {
private static ILog logger = LogManager.getLogger(AbstractClassEnhancePluginDefine.class);
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import net.bytebuddy.pool.TypePool;
import java.net.URL;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.util.StringUtil;
import com.a.eye.skywalking.api.util.StringUtil;
import java.io.BufferedReader;
import java.io.IOException;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
public class PluginException extends RuntimeException {
private static final long serialVersionUID = -6020188711867490724L;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import java.io.IOException;
import java.net.URL;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.dynamic.ClassFileLocator;
import net.bytebuddy.dynamic.DynamicType;
......
package com.a.eye.skywalking.plugin.bytebuddy;
package com.a.eye.skywalking.api.plugin.bytebuddy;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.bytebuddy;
package com.a.eye.skywalking.api.plugin.bytebuddy;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
import com.a.eye.skywalking.plugin.PluginException;
import com.a.eye.skywalking.api.plugin.PluginException;
public class EnhanceException extends PluginException {
private static final long serialVersionUID = -2234782755784217255L;
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Enhanced instance field type.
*
* Any plugins({@link com.a.eye.skywalking.plugin.AbstractClassEnhancePluginDefine}'s subclass) override
* {@link com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine#getConstructorsInterceptPoints}
* Any plugins({@link AbstractClassEnhancePluginDefine}'s subclass) override
* {@link ClassEnhancePluginDefine#getConstructorsInterceptPoints}
* or
* {@link com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine#getInstanceMethodsInterceptPoints}
* {@link ClassEnhancePluginDefine#getInstanceMethodsInterceptPoints}
* will add a field with this type.
*
* @author wusheng
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
public class InterceptorException extends RuntimeException {
private static final long serialVersionUID = 7846035239994885019L;
......
package com.a.eye.skywalking.plugin.interceptor;
package com.a.eye.skywalking.api.plugin.interceptor;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.interceptor.assist;
package com.a.eye.skywalking.api.plugin.interceptor.assist;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.InterceptorException;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.InterceptorException;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
/**
* {@link NoCocurrencyAceessObject} is an abstract class,
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.FieldProxy;
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.plugin.PluginException;
import com.a.eye.skywalking.plugin.interceptor.*;
import com.a.eye.skywalking.util.StringUtil;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
import com.a.eye.skywalking.api.plugin.PluginException;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.EnhanceException;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
import com.a.eye.skywalking.api.util.StringUtil;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.MethodDelegation;
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
/**
* Plugins, which only need enhance class static methods.
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.*;
import java.lang.reflect.Method;
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
/**
* Plugins, which only need enhance class static methods.
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.interceptor.loader.InterceptorInstanceLoader;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.Origin;
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import net.bytebuddy.implementation.bind.annotation.AllArguments;
import net.bytebuddy.implementation.bind.annotation.FieldProxy;
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
public interface FieldGetter {
Object getValue();
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
public interface FieldSetter {
void setValue(Object value);
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
/**
* The instance constructor's interceptor interface.
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
/**
* A interceptor, which intercept method's invocation.
......
package com.a.eye.skywalking.plugin.interceptor.enhance;
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
/**
* This is a method return value manipulator.
......
package com.a.eye.skywalking.plugin.interceptor.loader;
package com.a.eye.skywalking.api.plugin.interceptor.loader;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
......
package com.a.eye.skywalking.queue;
package com.a.eye.skywalking.api.queue;
import com.a.eye.skywalking.trace.TraceSegment;
import com.lmax.disruptor.EventFactory;
......
package com.a.eye.skywalking.queue;
package com.a.eye.skywalking.api.queue;
import com.a.eye.skywalking.conf.Config;
import com.a.eye.skywalking.context.TracerContext;
import com.a.eye.skywalking.context.TracerContextListener;
import com.a.eye.skywalking.api.conf.Config;
import com.a.eye.skywalking.api.context.TracerContext;
import com.a.eye.skywalking.api.context.TracerContextListener;
import com.a.eye.skywalking.health.report.HealthCollector;
import com.a.eye.skywalking.health.report.HeathReading;
import com.a.eye.skywalking.trace.TraceSegment;
......@@ -36,7 +36,7 @@ public enum TraceSegmentProcessQueue implements TracerContextListener {
RingBuffer<TraceSegmentHolder> buffer;
TraceSegmentProcessQueue() {
disruptor = new Disruptor<>(TraceSegmentHolder.Factory.INSTANCE, Config.Disruptor.BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
disruptor = new Disruptor<TraceSegmentHolder>(TraceSegmentHolder.Factory.INSTANCE, Config.Disruptor.BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
buffer = disruptor.getRingBuffer();
}
......
package com.a.eye.skywalking.util;
package com.a.eye.skywalking.api.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
......
package com.a.eye.skywalking.util;
package com.a.eye.skywalking.api.util;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
......
package com.a.eye.skywalking.util;
package com.a.eye.skywalking.api.util;
import com.a.eye.skywalking.conf.Constants;
import com.a.eye.skywalking.api.conf.Constants;
import java.util.UUID;
public final class TraceIdGenerator {
......
package com.a.eye.skywalking.context;
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
import com.a.eye.skywalking.trace.tag.Tags;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
......@@ -24,4 +25,9 @@ public class ContextManagerTestCase {
Assert.assertEquals(span, segment.getSpans().get(0));
}
@After
public void reset(){
TracerContext.ListenerManager.remove(TestTracerContextListener.INSTANCE);
}
}
package com.a.eye.skywalking.context;
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import java.io.IOException;
import com.a.eye.skywalking.plugin.PluginResourcesResolver;
public class PluginResourceResoverTest {
public static void main(String[] args) throws IOException {
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine;
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.StaticMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin;
package com.a.eye.skywalking.api.plugin;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.StaticMethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
public class TestStaticAroundInterceptor implements StaticMethodsAroundInterceptor {
......
package com.a.eye.skywalking.plugin.dubbo;
package com.a.eye.skywalking.api.plugin.dubbo;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.dubbo;
package com.a.eye.skywalking.api.plugin.dubbo;
import com.a.eye.skywalking.api.plugin.dubbox.bugfix.below283.BugFixAcitve;
import com.a.eye.skywalking.api.plugin.dubbox.bugfix.below283.SWBaseBean;
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
import com.a.eye.skywalking.invoke.monitor.RPCServerInvokeMonitor;
import com.a.eye.skywalking.model.ContextData;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.plugin.dubbox.bugfix.below283.BugFixAcitve;
import com.a.eye.skywalking.plugin.dubbox.bugfix.below283.SWBaseBean;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
......
package com.a.eye.skywalking.plugin.dubbox.bugfix.below283;
package com.a.eye.skywalking.api.plugin.dubbox.bugfix.below283;
public final class BugFixAcitve {
public static boolean isActive = false;
......
package com.a.eye.skywalking.plugin.httpClient.v4;
package com.a.eye.skywalking.api.plugin.httpClient.v4;
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
......@@ -8,8 +8,8 @@ import org.apache.http.HttpRequest;
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
/**
......
package com.a.eye.skywalking.plugin.httpClient.v4.define;
package com.a.eye.skywalking.api.plugin.httpClient.v4.define;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.httpClient.v4.define;
package com.a.eye.skywalking.api.plugin.httpClient.v4.define;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.httpClient.v4.define;
package com.a.eye.skywalking.api.plugin.httpClient.v4.define;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
......
package com.a.eye.skywalking.plugin.httpClient.v4.define;
package com.a.eye.skywalking.api.plugin.httpClient.v4.define;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.httpClient.v4.define;
package com.a.eye.skywalking.api.plugin.httpClient.v4.define;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
package com.a.eye.skywalking.plugin.jdbc;
package com.a.eye.skywalking.api.plugin.jdbc;
import com.a.eye.skywalking.api.plugin.jdbc.define.JDBCBuriedPointType;
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.plugin.jdbc.define.JDBCBuriedPointType;
import java.sql.SQLException;
......
package com.a.eye.skywalking.plugin.jdbc;
package com.a.eye.skywalking.api.plugin.jdbc;
import com.a.eye.skywalking.api.plugin.jdbc.define.JDBCBuriedPointType;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
import com.a.eye.skywalking.plugin.jdbc.define.JDBCBuriedPointType;
import java.sql.SQLException;
......
package com.a.eye.skywalking.plugin.jdbc;
package com.a.eye.skywalking.api.plugin.jdbc;
import com.a.eye.skywalking.context.ContextManager;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.tag.Tags;
import java.sql.SQLException;
......@@ -17,9 +17,9 @@ public class PreparedStatementTracing {
throws SQLException {
Span span = ContextManager.INSTANCE.createSpan("JDBC/PreparedStatement/" + method);
try {
Tags.SPAN_KIND.asDBAccess(span);
Tags.SPAN_LAYER.asRDB(span);
Tags.DB_URL.set(span, connectInfo);
Tags.DB_SQL.set(span, sql);
Tags.DB_STATEMENT.set(span, sql);
return exec.exe(realStatement, sql);
} catch (SQLException e) {
span.log(e);
......
package com.a.eye.skywalking.plugin.jdbc;
package com.a.eye.skywalking.api.plugin.jdbc;
import com.a.eye.skywalking.api.plugin.jdbc.define.JDBCBuriedPointType;
import com.a.eye.skywalking.model.Identification;
import com.a.eye.skywalking.invoke.monitor.RPCClientInvokeMonitor;
import com.a.eye.skywalking.plugin.jdbc.define.JDBCBuriedPointType;
import java.sql.SQLException;
......
package com.a.eye.skywalking.plugin.jdbc.define;
package com.a.eye.skywalking.api.plugin.jdbc.define;
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册