提交 5f062201 编写于 作者: P pengys5

Merge remote-tracking branch 'origin/master' into feature/collector

Sky Walking
==========
<img src="docs/resources/skywalking.png" alt="Sky Walking logo" height="90px" align="right" />
<img src="https://sky-walking.github.io/page-resources/3.0/skywalking.png" alt="Sky Walking logo" height="90px" align="right" />
SkyWalking: Large-Scale Distributed Systems Tracing Infrastructure, also known Distributed Tracer.
**SkyWalking 3.x**: APM for Distributed Systems, also known Distributed Tracing System.
[![Build Status](https://travis-ci.org/wu-sheng/sky-walking.svg?branch=master)](https://travis-ci.org/wu-sheng/sky-walking)
[![Coverage Status](https://coveralls.io/repos/github/wu-sheng/sky-walking/badge.svg?branch=master)](https://coveralls.io/github/wu-sheng/sky-walking?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/wu-sheng/sky-walking/badge.svg?branch=master&forceUpdate=2)](https://coveralls.io/github/wu-sheng/sky-walking?branch=master)
![license](https://img.shields.io/aur/license/yaourt.svg)
[![codebeat badge](https://codebeat.co/badges/579e4dce-1dc7-4f32-a163-c164eafa1335)](https://codebeat.co/projects/github-com-wu-sheng-sky-walking)
[![Join the chat at https://gitter.im/sky-walking/Lobby](https://badges.gitter.im/sky-walking/Lobby.svg)](https://gitter.im/sky-walking/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![OpenTracing-1.0 Badge](https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg)](http://opentracing.io)
[![Release Version](https://img.shields.io/badge/stable-2.3--2017-brightgreen.svg)](https://github.com/wu-sheng/sky-walking/releases)
[![Release Version](https://img.shields.io/badge/tesing-3.0--2017-yellow.svg)](https://github.com/wu-sheng/sky-walking/releases)
# News
* sky-walking v3.0 iteration begins... The top 2 important features are: [`Update the trace-structure`](https://github.com/wu-sheng/sky-walking/issues/83) and [`Analyze trace, and bring metric/analytic/cause up`](https://github.com/wu-sheng/sky-walking/issues/84)
* See feature codes at [branch feature/3.0](https://github.com/wu-sheng/sky-walking/tree/feature/3.0)
* The new UI release on [wu-sheng/sky-walking-ui](https://github.com/wu-sheng/sky-walking-ui)
# 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.
* 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 implementation. provide HTTP (since 2.1) cross-platform spans collecting service.
* High performance stream process.
# Supported components
### web containers
* Tomcat 7
* Tomcat 8
### databases
* mysql
* oracle
* h2
* easily extend to support sybase, sqlserver, jtds, db2, informix
### rpc frameworks
* dubbo
* dubbox
* httpClient
* motan
### cache
* jedis
### opentracing supported frameworks
* motan
* hprose-java
# Contributors
* 吴晟 [wusheng](https://github.com/wu-sheng) &nbsp;&nbsp;wu.sheng@foxmail.com
* 张鑫 [zhangxin](https://github.com/ascrutae) &nbsp;&nbsp;
_Chinese Articles about sky-walking and distributed tracer_
<img src="docs/resources/toutiao.JPG" alt="Sky Walking TouTiao" height="280px" />
_If you are Chinese Developer, you can join QQ Group: 392443393, and **Tagged** Sky-Walking._
* Auto-instrumentation mechanism, **no need to CHANGE any application source code**. Supported [frameworks](https://github.com/wu-sheng/sky-walking/wiki/3.0-supported-list).
* Pure Java server implementation, with RESTful Web service.
* High performance streaming analysis.
* The UI released on [wu-sheng/sky-walking-ui](https://github.com/wu-sheng/sky-walking-ui)
___
<a href="https://github.com/wu-sheng/sky-walking">
<img src="docs/resources/oneapm-award.png" alt="OneAPM Open Source Achievement Award" height="110px" align="left" />
<img src="https://sky-walking.github.io/page-resources/3.0/oneapm-award.png" alt="OneAPM Open Source Achievement Award" height="110px" align="left" />
</a>
In October 2016, Sky Walking won `OneAPM Open Source Achievement Award`. The award appreciates sky walking for its "*contribution to popularization of APM technology*". <br/>
[OneAPM](http://www.oneapm.com/) will provide financial support for the project in 2016-2017.<br/><br/>
[OneAPM](http://www.oneapm.com/) provides financial support for the project in 2016-2017.<br/><br/>
Thanks all users of sky walking project.
___
# Contributors
_In chronological order_
* 吴晟 [@wu-sheng](https://github.com/wu-sheng)
* 张鑫 [@ascrutae](https://github.com/ascrutae)
* 谭真 [@mircoteam](https://github.com/mircoteam)
* 徐妍 [@TastySummer](https://github.com/TastySummer)
* 彭勇升 [@pengys5](https://github.com/pengys5)
* 戴文
# Quick View
* distributed trace
![追踪连路图1](docs/resources/callChain.png?1=1)
![追踪连路图2](docs/resources/callChainDetail.png?1=1)
# Screenshots
- Topological graph of application clusters.
<img src="https://sky-walking.github.io/page-resources/3.0/topological_graph.png?forceUpdate=1"/>
![追踪连路图3](docs/resources/callChainLog.png?1=1)
- Trace query.
<img src="https://sky-walking.github.io/page-resources/3.0/trace_segment.png"/>
* alarm mail
- Span detail.
<img src="https://sky-walking.github.io/page-resources/3.0/span.png" />
![告警邮件](docs/resources/alarmMail.png?1=1)
# Document
* [WIKI](https://github.com/wu-sheng/sky-walking/wiki)
_Chat with us on gitter, in English. As a Chinese Developer, you can join QQ Group: 392443393, and **Tagged** Sky-Walking._
_sky-walking 1.x and 2.x provide features about tracing only, did not include any analysis abilities._
......@@ -24,6 +24,21 @@
<name>Zhang Xin</name>
<url>https://github.com/ascrutae</url>
</developer>
<developer>
<name>Tan Zhen</name>
<url>https://github.com/mircoteam</url>
</developer>
<developer>
<name>Xu Yan</name>
<url>https://github.com/TastySummer</url>
</developer>
<developer>
<name>Peng Yongsheng</name>
<url>https://github.com/pengys5</url>
</developer>
<developer>
<name>Dai Wen</name>
</developer>
</developers>
<modules>
......
......@@ -94,6 +94,9 @@ public class SkyWalkingSpanBuilder implements Tracer.SpanBuilder {
@Override
public Span start() {
if (startTime == 0){
startTime = System.currentTimeMillis();
}
return new SkyWalkingSpan(this.operationName, this.startTime, this.tags);
}
......
......@@ -24,6 +24,13 @@ public abstract class DistributedTraceId {
return id;
}
/**
* Compare the two <code>DistributedTraceId</code> by its {@link #id},
* even these two <code>DistributedTraceId</code>s are not the same instances.
*
* @param o target <code>DistributedTraceId</code>
* @return return if they have the same {@link #id}
*/
@Override
public boolean equals(Object o) {
if (this == o)
......
......@@ -100,8 +100,7 @@ public class TraceSegment {
private boolean sampled;
/**
* Create a trace segment, by given segmentId.
* This segmentId is generated by TraceSegmentRef, AKA, from tracer/agent module.
* Create a trace segment, by the given applicationCode.
*/
public TraceSegment(String applicationCode) {
this();
......@@ -109,7 +108,9 @@ public class TraceSegment {
}
/**
* Create a default/empty trace segment
* Create a default/empty trace segment,
* with current time as start time,
* and generate a new segment id.
*/
public TraceSegment() {
this.startTime = System.currentTimeMillis();
......@@ -134,6 +135,11 @@ public class TraceSegment {
}
}
/**
* Establish the line between this segment and all relative global trace ids.
*
* @param distributedTraceIds multi global trace ids. @see {@link DistributedTraceId}
*/
public void relatedGlobalTraces(List<DistributedTraceId> distributedTraceIds) {
if (distributedTraceIds == null || distributedTraceIds.size() == 0) {
return;
......
......@@ -30,15 +30,11 @@ import org.apache.http.impl.client.HttpClients;
public class CollectorClient implements Runnable {
private static ILog logger = LogManager.getLogger(CollectorClient.class);
private static long SLEEP_TIME_MILLIS = 500;
private CloseableHttpClient httpclient;
private String[] serverList;
private volatile int selectedServer = -1;
public CollectorClient() {
serverList = Config.Collector.SERVERS.split(",");
httpclient = HttpClients.custom()
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy())
.build();
Random r = new Random();
if (serverList.length > 0) {
selectedServer = r.nextInt(serverList.length);
......@@ -92,11 +88,11 @@ public class CollectorClient implements Runnable {
.excludeFieldsWithoutExposeAnnotation()
.create();
String messageJson = gson.toJson(message);
CloseableHttpClient httpClient = HttpClients.custom().build();
try {
HttpPost httpPost = ready2Send(messageJson);
if (httpPost != null) {
CloseableHttpResponse httpResponse = httpclient.execute(httpPost);
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (200 != statusCode) {
findBackupServer();
......@@ -106,6 +102,8 @@ public class CollectorClient implements Runnable {
} catch (IOException e) {
findBackupServer();
throw e;
}finally {
httpClient.close();
}
}
......
package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.api.boot.BootService;
import com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
......@@ -44,21 +43,14 @@ public class ContextManager implements TracerContextListener, BootService {
}
/**
* @see {@link TracerContext#extract(ContextCarrier)}
* @return the first global trace id if exist. Otherwise, "N/A".
*/
public static void multiExtract(ContextCarrier carrier){
get().extract(carrier);
}
/**
* @return the {@link TraceSegment#traceSegmentId} if exist. Otherwise, "N/A".
*/
public static String getTraceSegmentId(){
public static String getGlobalTraceId(){
TracerContext segment = CONTEXT.get();
if(segment == null){
return "N/A";
}else{
return segment.getTraceSegmentId();
return segment.getGlobalTraceId();
}
}
......
......@@ -91,10 +91,10 @@ public final class TracerContext {
}
/**
* @return the current trace segment id.
* @return the current trace id.
*/
String getTraceSegmentId(){
return segment.getTraceSegmentId();
String getGlobalTraceId(){
return segment.getRelatedGlobalTraces().get(0).get();
}
public void stopSpan(Span span, Long endTime){
......
package com.a.eye.skywalking.toolkit.activation.log.log4j.v1.x;
import com.a.eye.skywalking.api.context.ContextCarrier;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
......@@ -26,7 +25,7 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
*/
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
return "TID:" + ContextManager.getTraceSegmentId();
return "TID:" + ContextManager.getGlobalTraceId();
}
@Override
......
package com.a.eye.skywalking.toolkit.activation.log.log4j.v2.x;
import com.a.eye.skywalking.api.context.ContextCarrier;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
......@@ -19,7 +18,7 @@ public class PrintTraceIdInterceptor implements StaticMethodsAroundInterceptor {
*/
@Override
public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + ContextManager.getTraceSegmentId());
((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + ContextManager.getGlobalTraceId());
//make sure origin method do not invoke.
result.defineReturnValue(null);
......
......@@ -25,7 +25,7 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
*/
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
return "TID:" + ContextManager.getTraceSegmentId();
return "TID:" + ContextManager.getGlobalTraceId();
}
@Override
......
package com.a.eye.skywalking.toolkit.activation.trace;
import com.a.eye.skywalking.api.context.ContextCarrier;
import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.logging.ILog;
import com.a.eye.skywalking.logging.LogManager;
......@@ -24,7 +23,7 @@ public class TraceContextInterceptor implements StaticMethodsAroundInterceptor {
@Override
public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
return ContextManager.getTraceSegmentId();
return ContextManager.getGlobalTraceId();
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册