Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
b88b3559
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b88b3559
编写于
7月 08, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize codes and add more comments.
上级
b32ee4ce
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
16 deletion
+105
-16
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
...kywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
+3
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
...walking/apm/agent/core/context/AbstractTracerContext.java
+69
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
...org/skywalking/apm/agent/core/context/ContextManager.java
+2
-16
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
...org/skywalking/apm/agent/core/context/TracingContext.java
+31
-0
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/RemoteDownstreamConfig.java
浏览文件 @
b88b3559
...
...
@@ -5,6 +5,9 @@ import java.util.List;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
/**
* The <code>RemoteDownstreamConfig</code> includes configurations from collector side.
* All of them initialized null, Null-Value or empty collection.
*
* @author wusheng
*/
public
class
RemoteDownstreamConfig
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
浏览文件 @
b88b3559
package
org.skywalking.apm.agent.core.context
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.EntrySpan
;
import
org.skywalking.apm.agent.core.context.trace.ExitSpan
;
import
org.skywalking.apm.agent.core.context.trace.LocalSpan
;
/**
* The <code>AbstractTracerContext</code> represents the tracer context manager.
...
...
@@ -8,23 +11,89 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
* @author wusheng
*/
public
interface
AbstractTracerContext
{
/**
* Prepare for the cross-process propagation.
* How to initialize the carrier, depends on the implementation.
*
* @param carrier to carry the context for crossing process.
* @see {@link TracingContext} and {@link IgnoredTracerContext}
*/
void
inject
(
ContextCarrier
carrier
);
/**
* Build the reference between this segment and a cross-process segment.
* How to build, depends on the implementation.
*
* @param carrier carried the context from a cross-process segment.
* @see {@link TracingContext} and {@link IgnoredTracerContext}
*/
void
extract
(
ContextCarrier
carrier
);
/**
* Capture a snapshot for cross-thread propagation.
* It's a similar concept with ActiveSpan.Continuation in OpenTracing-java
* How to build, depends on the implementation.
*
* @return the {@link ContextSnapshot} , which includes the reference context.
* @see {@link TracingContext} and {@link IgnoredTracerContext}
*/
ContextSnapshot
capture
();
/**
* Build the reference between this segment and a cross-thread segment.
* How to build, depends on the implementation.
*
* @param snapshot from {@link #capture()} in the parent thread.
* @see {@link TracingContext} and {@link IgnoredTracerContext}
*/
void
continued
(
ContextSnapshot
snapshot
);
/**
* Get the global trace id, if exist.
* How to build, depends on the implementation.
*
* @return the string represents the id.
* @see {@link TracingContext} and {@link IgnoredTracerContext}
*/
String
getGlobalTraceId
();
/**
* Create an entry span
*
* @param operationName most likely a service name
* @return the span represents an entry point of this segment.
* @see {@link EntrySpan} if the implementation is {@link TracingContext}
*/
AbstractSpan
createEntrySpan
(
String
operationName
);
/**
* Create a local span
*
* @param operationName most likely a local method signature, or business name.
* @return the span represents a local logic block.
* @see {@link LocalSpan} if the implementation is {@link TracingContext}
*/
AbstractSpan
createLocalSpan
(
String
operationName
);
/**
* Create an exit span
*
* @param operationName most likely a service name of remote
* @param remotePeer the network id(ip:port, hostname:port or ip1:port1,ip2,port, etc.)
* @return the span represent an exit point of this segment.
* @see {@link ExitSpan} if the implementation is {@link TracingContext}
*/
AbstractSpan
createExitSpan
(
String
operationName
,
String
remotePeer
);
/**
* @return the active span of current tracing context(stack)
*/
AbstractSpan
activeSpan
();
/**
* Finish the given span, and the given span should be the active span of current tracing context(stack)
*
* @param span to finish
*/
void
stopSpan
(
AbstractSpan
span
);
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
b88b3559
...
...
@@ -108,25 +108,11 @@ public class ContextManager implements TracingContextListener, BootService, Igno
}
public
static
void
inject
(
ContextCarrier
contextCarrier
)
{
AbstractSpan
span
=
activeSpan
();
if
(
span
instanceof
AbstractTracingSpan
)
{
if
(
span
.
isExit
())
{
get
().
inject
(
contextCarrier
);
}
else
{
throw
new
IllegalStateException
(
"Can't do inject when the active span isn't an exit span"
);
}
}
get
().
inject
(
contextCarrier
);
}
public
static
void
extract
(
ContextCarrier
contextCarrier
)
{
AbstractSpan
span
=
activeSpan
();
if
(
span
instanceof
AbstractTracingSpan
)
{
if
(
span
.
isEntry
())
{
get
().
extract
(
contextCarrier
);
}
else
{
throw
new
IllegalStateException
(
"Can't do extract when the active span isn't an entry span"
);
}
}
get
().
extract
(
contextCarrier
);
}
public
ContextSnapshot
capture
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
b88b3559
...
...
@@ -16,11 +16,29 @@ import org.skywalking.apm.agent.core.dictionary.PossibleFound;
import
org.skywalking.apm.agent.core.sampling.SamplingService
;
/**
* The <code>TracingContext</code> represents a core tracing logic controller.
* It build the final {@link TracingContext}, by the stack mechanism,
* which is similar with the codes work.
*
* In opentracing concept, it means, all spans in a segment tracing context(thread)
* are CHILD_OF relationship, but no FOLLOW_OF.
*
* In skywalking core concept, FOLLOW_OF is an abstract concept
* when cross-process MQ or cross-thread async/batch tasks happen,
* we used {@link TraceSegmentRef} for these scenarios.
* Check {@link TraceSegmentRef} which is from {@link ContextCarrier} or {@link ContextSnapshot}.
*
* @author wusheng
*/
public
class
TracingContext
implements
AbstractTracerContext
{
/**
* @see {@link SamplingService}
*/
private
SamplingService
samplingService
;
/**
* The final {@link TraceSegment}, which includes all finished spans.
*/
private
TraceSegment
segment
;
/**
...
...
@@ -32,8 +50,14 @@ public class TracingContext implements AbstractTracerContext {
*/
private
LinkedList
<
AbstractTracingSpan
>
activeSpanStack
=
new
LinkedList
<
AbstractTracingSpan
>();
/**
* A counter for the next span.
*/
private
int
spanIdGenerator
;
/**
* Initialize all fields with default value.
*/
TracingContext
()
{
this
.
segment
=
new
TraceSegment
();
this
.
spanIdGenerator
=
0
;
...
...
@@ -42,6 +66,13 @@ public class TracingContext implements AbstractTracerContext {
}
}
/**
* Inject the context into the given carrier, only when the active span is an exit one.
*
* @param carrier to carry the context for crossing process.
* @see {@link AbstractTracerContext#inject(ContextCarrier)}
* @throws IllegalStateException, if the active span isn't an exit one.
*/
@Override
public
void
inject
(
ContextCarrier
carrier
)
{
AbstractTracingSpan
span
=
this
.
activeSpan
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录