diff --git a/README.md b/README.md index b21ce80a7..9fb23ff76 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,10 @@ SkyWalking: Large-Scale Distributed Systems Tracing Infrastructure, also known D # Abstract * An open source Large-Scale Distributed Systems Tracing Infrastructure, also known a ditributed tracer. * Based on [Google Dapper Paper: Dapper, a Large-Scale Distributed Systems Tracing Infrastructure](http://research.google.com/pubs/pub36356.html), [read Simplified Chinese Version](http://duanple.blog.163.com/blog/static/70971767201329113141336/) -* Support popular rpc frameworks, such as [dubbo](https://github.com/alibaba/dubbo), [dubbox](https://github.com/dangdangdotcom/dubbox), [motan](https://github.com/weibocom/motan) etc., trigger email-alert when application occurs unexpected exception。 +* Support popular rpc frameworks, such as [dubbo](https://github.com/alibaba/dubbo), [dubbox](https://github.com/dangdangdotcom/dubbox), [motan](https://github.com/weibocom/motan) etc., trigger email-alert when application occurs unexpected exception. +* Auto-instrumentation mechenism, **no need to CHANGE any application source code**. * Easy to deploy, **even in product mode** (since 2.0) . No need of Hadoop, HBase, or Cassandra Cluster. -* Pure Java server implements. provide gRPC (since 2.0) and HTTP (since 2.1) cross-platform spans collecting service. +* Pure Java server implementation. provide gRPC (since 2.0) and HTTP (since 2.1) cross-platform spans collecting service. # Supported components diff --git a/pom.xml b/pom.xml index 87982d307..4d96b5330 100644 --- a/pom.xml +++ b/pom.xml @@ -105,9 +105,11 @@ false - DataCarrier + bintray bintray https://jcenter.bintray.com + + diff --git a/skywalking-application-toolkit/pom.xml b/skywalking-application-toolkit/pom.xml index 4fe3974d8..c8b3e2d12 100644 --- a/skywalking-application-toolkit/pom.xml +++ b/skywalking-application-toolkit/pom.xml @@ -18,5 +18,6 @@ skywalking-toolkit-log4j-2.x skywalking-toolkit-logback-1.x skywalking-toolkit-trace-context + skywalking-toolkit-opentracing diff --git a/skywalking-application-toolkit/skywalking-toolkit-log4j-1.x/pom.xml b/skywalking-application-toolkit/skywalking-toolkit-log4j-1.x/pom.xml index 91ebc8d49..c36240962 100644 --- a/skywalking-application-toolkit/skywalking-toolkit-log4j-1.x/pom.xml +++ b/skywalking-application-toolkit/skywalking-toolkit-log4j-1.x/pom.xml @@ -20,4 +20,32 @@ + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + + jar + + + + 2.4 + + + + + + + bintray-wu-sheng-sky-walking-repository + wu-sheng-sky-walking-repository + https://api.bintray.com/maven/wu-sheng/skywalking/com.a.eye.skywalking-toolkit-log4j-1.x/;publish=1 + + diff --git a/skywalking-application-toolkit/skywalking-toolkit-log4j-2.x/pom.xml b/skywalking-application-toolkit/skywalking-toolkit-log4j-2.x/pom.xml index 584789b85..7c9285bd4 100644 --- a/skywalking-application-toolkit/skywalking-toolkit-log4j-2.x/pom.xml +++ b/skywalking-application-toolkit/skywalking-toolkit-log4j-2.x/pom.xml @@ -16,7 +16,36 @@ org.apache.logging.log4j log4j-core 2.7 - compile + provided + + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + + jar + + + + 2.4 + + + + + + + bintray-wu-sheng-sky-walking-repository + wu-sheng-sky-walking-repository + https://api.bintray.com/maven/wu-sheng/skywalking/com.a.eye.skywalking-toolkit-log4j-2.x/;publish=1 + + diff --git a/skywalking-application-toolkit/skywalking-toolkit-logback-1.x/pom.xml b/skywalking-application-toolkit/skywalking-toolkit-logback-1.x/pom.xml index f970cc992..5033dc7b2 100644 --- a/skywalking-application-toolkit/skywalking-toolkit-logback-1.x/pom.xml +++ b/skywalking-application-toolkit/skywalking-toolkit-logback-1.x/pom.xml @@ -16,6 +16,36 @@ ch.qos.logback logback-classic 1.1.7 + provided + + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + + jar + + + + 2.4 + + + + + + + bintray-wu-sheng-sky-walking-repository + wu-sheng-sky-walking-repository + https://api.bintray.com/maven/wu-sheng/skywalking/com.a.eye.skywalking-toolkit-logback-1.x/;publish=1 + + diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/pom.xml b/skywalking-application-toolkit/skywalking-toolkit-opentracing/pom.xml new file mode 100644 index 000000000..be3ccede1 --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/pom.xml @@ -0,0 +1,26 @@ + + + + skywalking-application-toolkit + com.a.eye + 2.1-2017 + + 4.0.0 + + skywalking-toolkit-opentracing + + + + io.opentracing + opentracing-api + 0.20.4 + + + io.opentracing + opentracing-noop + 0.20.4 + + + diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/ByteBufferContext.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/ByteBufferContext.java new file mode 100644 index 000000000..f919e3fd1 --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/ByteBufferContext.java @@ -0,0 +1,29 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.SpanContext; + +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by wusheng on 2016/12/21. + */ +public class ByteBufferContext implements SpanContext { + static final Charset CHARSET = Charset.forName("UTF-8"); + + static final byte NO_ENTRY = 0; + static final byte ENTRY = 1; + + private final ByteBuffer byteBuffer; + + ByteBufferContext(ByteBuffer byteBuffer) { + this.byteBuffer = byteBuffer; + } + + @Override + public Iterable> baggageItems() { + return new HashMap().entrySet(); + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpan.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpan.java new file mode 100644 index 000000000..f4903c53b --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpan.java @@ -0,0 +1,113 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.Span; +import io.opentracing.SpanContext; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by wusheng on 2016/12/20. + */ +public class SkyWalkingSpan implements Span, SpanContext { + private String operationName; + + private long startTime; + + private Map tags; + + private final Map baggageItems; + + SkyWalkingSpan(String operationName, long startTime, Map tags){ + this.operationName = operationName; + this.startTime = startTime; + this.tags = tags; + baggageItems = new HashMap(); + } + + @Override + public SpanContext context() { + return this; + } + + @Override + public void finish() { + + } + + @Override + public void finish(long finishMicros) { + + } + + @Override + public void close() { + + } + + @Override + public Span setTag(String key, String value) { + return this; + } + + @Override + public Span setTag(String key, boolean value) { + return this; + } + + @Override + public Span setTag(String key, Number value) { + return this; + } + + @Override + public Span log(Map fields) { + return this; + } + + @Override + public Span log(long timestampMicroseconds, Map fields) { + return this; + } + + @Override + public Span log(String event) { + return this; + } + + @Override + public Span log(long timestampMicroseconds, String event) { + return this; + } + + @Override + public Span setBaggageItem(String key, String value) { + baggageItems.put(key, value); + return this; + } + + @Override + public String getBaggageItem(String key) { + return baggageItems.get(key); + } + + @Override + public Span setOperationName(String operationName) { + return this; + } + + @Override + public Span log(String eventName, Object payload) { + return this; + } + + @Override + public Span log(long timestampMicroseconds, String eventName, Object payload) { + return this; + } + + @Override + public Iterable> baggageItems() { + return baggageItems.entrySet(); + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpanBuilder.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpanBuilder.java new file mode 100644 index 000000000..15cc19d21 --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingSpanBuilder.java @@ -0,0 +1,106 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.References; +import io.opentracing.Span; +import io.opentracing.SpanContext; +import io.opentracing.Tracer; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * All source code in SkyWalkingSpanBuilder acts like an NoopSpanBuilder. + * Actually, it is NOT. + * The whole logic will be added after toolkit-activation. + * + * Created by wusheng on 2016/12/20. + */ +public class SkyWalkingSpanBuilder implements Tracer.SpanBuilder { + private String operationName; + + private long startTime = 0L; + + private final Map tags; + + private SpanContext parentContext; + + SkyWalkingSpanBuilder(String operationName){ + this.operationName = operationName; + this.tags = new HashMap(); + } + + /** + * In SkyWalkingTracer, SpanContext will not be used. Tracer will build reference by itself. + * + * @param spanContext + * @return + */ + @Override + public Tracer.SpanBuilder asChildOf(SpanContext spanContext) { + this.parentContext = spanContext; + return this; + } + + /** + * In SkyWalkingTracer, Parent Span will not be used. Tracer will build reference by itself. + * @param span + * @return + */ + @Override + public Tracer.SpanBuilder asChildOf(Span span) { + asChildOf(span.context()); + return this; + } + + @Override + public Tracer.SpanBuilder addReference(String referenceType, SpanContext referencedContext) { + if (referenceType.equals(References.CHILD_OF)) { + return asChildOf(referencedContext); + } else { + return this; + } + } + + @Override + public Tracer.SpanBuilder withTag(String key, String value) { + if (key != null && value != null) { + tags.put(key, value); + } + return this; + } + + @Override + public Tracer.SpanBuilder withTag(String key, boolean value) { + if (key != null) { + tags.put(key, Boolean.toString(value)); + } + return this; + } + + @Override + public Tracer.SpanBuilder withTag(String key, Number value) { + if (key != null && value != null) { + tags.put(key, value.toString()); + } + return this; + } + + @Override + public Tracer.SpanBuilder withStartTimestamp(long startTime) { + this.startTime = startTime; + return this; + } + + @Override + public Span start() { + return new SkyWalkingSpan(this.operationName, this.startTime, this.tags); + } + + @Override + public Iterable> baggageItems() { + return parentContext == null + ? Collections.emptyMap().entrySet() + : parentContext.baggageItems(); + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracer.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracer.java new file mode 100644 index 000000000..eb3f851be --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracer.java @@ -0,0 +1,86 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.SpanContext; +import io.opentracing.Tracer; +import io.opentracing.propagation.Format; +import io.opentracing.propagation.TextMap; + +import java.nio.ByteBuffer; + +/** + * All source code in SkyWalkingTracer acts like an NoopTracer. + * Actually, it is NOT. + * The whole logic will be added after toolkit-activation. + *

+ * Created by wusheng on 2016/12/20. + */ +public class SkyWalkingTracer implements Tracer { + private static String TRACE_HEAD_NAME = "SkyWalking-TRACING-NAME"; + + public static Tracer INSTANCE = new SkyWalkingTracer(); + + @Override + public SpanBuilder buildSpan(String operationName) { + return new SkyWalkingSpanBuilder(operationName); + } + + @Override + public void inject(SpanContext spanContext, Format format, C carrier) { + if (Format.Builtin.TEXT_MAP.equals(format) || Format.Builtin.HTTP_HEADERS.equals(format)) { + ((TextMap) carrier).put(TRACE_HEAD_NAME, formatCrossProcessPropagationContextData()); + } else if (Format.Builtin.BINARY.equals(format)) { + byte[] key = TRACE_HEAD_NAME.getBytes(ByteBufferContext.CHARSET); + byte[] value = formatCrossProcessPropagationContextData().getBytes(ByteBufferContext.CHARSET); + ((ByteBuffer) carrier).put(ByteBufferContext.ENTRY); + ((ByteBuffer) carrier).putInt(key.length); + ((ByteBuffer) carrier).putInt(value.length); + ((ByteBuffer) carrier).put(key); + ((ByteBuffer) carrier).put(value); + } else { + throw new IllegalArgumentException("Unsupported format: " + format); + } + } + + @Override + public SpanContext extract(Format format, C carrier) { + if (Format.Builtin.TEXT_MAP.equals(format) || Format.Builtin.HTTP_HEADERS.equals(format)) { + TextMap textMapCarrier = (TextMap) carrier; + extractCrossProcessPropagationContextData(textMapCarrier); + return new TextMapContext(textMapCarrier); + } else if (Format.Builtin.BINARY.equals(format)) { + ByteBuffer byteBufferCarrier = (ByteBuffer)carrier; + extractCrossProcessPropagationContextData(byteBufferCarrier); + return new ByteBufferContext((ByteBuffer)carrier); + } else { + throw new IllegalArgumentException("Unsupported format: " + format); + } + } + + + /** + * set context data in toolkit-opentracing-activation + * + * @return + */ + private String formatCrossProcessPropagationContextData() { + return ""; + } + + /** + * read context data in toolkit-opentracing-activation + * + * @param textMapCarrier + */ + private void extractCrossProcessPropagationContextData(TextMap textMapCarrier) { + + } + + /** + * read context data in toolkit-opentracing-activation + * + * @param byteBufferCarrier + */ + private void extractCrossProcessPropagationContextData(ByteBuffer byteBufferCarrier) { + + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/TextMapContext.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/TextMapContext.java new file mode 100644 index 000000000..66d1f443b --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/java/com/a/eye/skywalking/toolkit/opentracing/TextMapContext.java @@ -0,0 +1,23 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.SpanContext; +import io.opentracing.propagation.TextMap; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by wusheng on 2016/12/21. + */ +public class TextMapContext implements SpanContext { + private final TextMap textMap; + + TextMapContext(TextMap textMap) { + this.textMap = textMap; + } + + @Override + public Iterable> baggageItems() { + return new HashMap().entrySet(); + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/resources/META-INF.services/io.opentracing.Tracer b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/resources/META-INF.services/io.opentracing.Tracer new file mode 100644 index 000000000..728fcb10e --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/main/resources/META-INF.services/io.opentracing.Tracer @@ -0,0 +1 @@ +com.a.eye.skywalking.toolkit.opentracing.SkyWalkingTracer diff --git a/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/test/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracerTest.java b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/test/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracerTest.java new file mode 100644 index 000000000..159e905aa --- /dev/null +++ b/skywalking-application-toolkit/skywalking-toolkit-opentracing/src/test/java/com/a/eye/skywalking/toolkit/opentracing/SkyWalkingTracerTest.java @@ -0,0 +1,39 @@ +package com.a.eye.skywalking.toolkit.opentracing; + +import io.opentracing.Span; +import io.opentracing.SpanContext; +import io.opentracing.Tracer; +import io.opentracing.propagation.TextMap; +import org.junit.Test; + +import java.util.Iterator; +import java.util.Map; + +/** + * Created by wusheng on 2016/12/21. + */ +public class SkyWalkingTracerTest { + @Test + public void testBuildSpan(){ + Tracer tracer = SkyWalkingTracer.INSTANCE; + Tracer.SpanBuilder spanBuilder = tracer.buildSpan("/http/serviceName"); + + SpanContext context = new TextMapContext(new TextMap() { + + @Override + public Iterator> iterator() { + throw new UnsupportedOperationException( + "TextMapInjectAdapter should only be used with Tracer.inject()"); + } + + @Override + public void put(String key, String value) { + + } + }); + spanBuilder.asChildOf(context).withTag("example.tag", "testtag"); + Span span = spanBuilder.start(); + + span.finish(); + } +} diff --git a/skywalking-application-toolkit/skywalking-toolkit-trace-context/pom.xml b/skywalking-application-toolkit/skywalking-toolkit-trace-context/pom.xml index dd14d276a..d82f4fd01 100644 --- a/skywalking-application-toolkit/skywalking-toolkit-trace-context/pom.xml +++ b/skywalking-application-toolkit/skywalking-toolkit-trace-context/pom.xml @@ -11,6 +11,33 @@ skywalking-toolkit-trace-context jar - skywalking-toolkit-trace-context http://maven.apache.org + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + + jar + + + + 2.4 + + + + + + + bintray-wu-sheng-sky-walking-repository + wu-sheng-sky-walking-repository + https://api.bintray.com/maven/wu-sheng/skywalking/com.a.eye.skywalking-toolkit-trace-context/;publish=1 + + diff --git a/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml b/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml index e54bf1c87..a597e2a39 100644 --- a/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml +++ b/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ skywalking-sniffer com.a.eye - ${skywalking.version} + 2.0-2016 4.0.0 skywalking-agent