Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
930e73f1
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
930e73f1
编写于
3月 14, 2019
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish the context based on #stopSpan result, rather than listener.
上级
b3e04356
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
33 deletion
+17
-33
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AbstractTracerContext.java
...walking/apm/agent/core/context/AbstractTracerContext.java
+2
-1
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AsyncSpan.java
...g/apache/skywalking/apm/agent/core/context/AsyncSpan.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
...che/skywalking/apm/agent/core/context/ContextManager.java
+4
-14
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManagerExtendService.java
...g/apm/agent/core/context/ContextManagerExtendService.java
+1
-8
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContext.java
...ywalking/apm/agent/core/context/IgnoredTracerContext.java
+6
-8
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
...che/skywalking/apm/agent/core/context/TracingContext.java
+3
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AbstractTracerContext.java
浏览文件 @
930e73f1
...
...
@@ -98,8 +98,9 @@ public interface AbstractTracerContext {
* Finish the given span, and the given span should be the active span of current tracing context(stack)
*
* @param span to finish
* @return true when context should be clear.
*/
void
stopSpan
(
AbstractSpan
span
);
boolean
stopSpan
(
AbstractSpan
span
);
/**
* Notify this context, current span is going to be finished async in another thread.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AsyncSpan.java
浏览文件 @
930e73f1
...
...
@@ -33,7 +33,7 @@ public interface AsyncSpan {
* called.
*
* This method must be called
*
*
* 1. In original thread(tracing context).
* 2. Current span is active span.
*
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
930e73f1
...
...
@@ -36,7 +36,7 @@ import org.apache.skywalking.apm.util.StringUtil;
*
* @author wusheng
*/
public
class
ContextManager
implements
TracingContextListener
,
BootService
,
IgnoreTracerContextListener
{
public
class
ContextManager
implements
BootService
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
ContextManager
.
class
);
private
static
ThreadLocal
<
AbstractTracerContext
>
CONTEXT
=
new
ThreadLocal
<
AbstractTracerContext
>();
private
static
ThreadLocal
<
RuntimeContext
>
RUNTIME_CONTEXT
=
new
ThreadLocal
<
RuntimeContext
>();
...
...
@@ -166,7 +166,9 @@ public class ContextManager implements TracingContextListener, BootService, Igno
}
public
static
void
stopSpan
(
AbstractSpan
span
)
{
get
().
stopSpan
(
span
);
if
(
get
().
stopSpan
(
span
))
{
CONTEXT
.
remove
();
}
}
@Override
...
...
@@ -176,8 +178,6 @@ public class ContextManager implements TracingContextListener, BootService, Igno
@Override
public
void
boot
()
{
ContextManagerExtendService
service
=
ServiceManager
.
INSTANCE
.
findService
(
ContextManagerExtendService
.
class
);
service
.
registerListeners
(
this
);
}
@Override
...
...
@@ -189,16 +189,6 @@ public class ContextManager implements TracingContextListener, BootService, Igno
}
@Override
public
void
afterFinished
(
TraceSegment
traceSegment
)
{
CONTEXT
.
remove
();
}
@Override
public
void
afterFinished
(
IgnoredTracerContext
traceSegment
)
{
CONTEXT
.
remove
();
}
public
static
boolean
isActive
()
{
return
get
()
!=
null
;
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManagerExtendService.java
浏览文件 @
930e73f1
...
...
@@ -18,9 +18,7 @@
package
org.apache.skywalking.apm.agent.core.context
;
import
org.apache.skywalking.apm.agent.core.boot.BootService
;
import
org.apache.skywalking.apm.agent.core.boot.DefaultImplementor
;
import
org.apache.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.apache.skywalking.apm.agent.core.boot.*
;
import
org.apache.skywalking.apm.agent.core.conf.Config
;
import
org.apache.skywalking.apm.agent.core.sampling.SamplingService
;
...
...
@@ -45,11 +43,6 @@ public class ContextManagerExtendService implements BootService {
}
public
void
registerListeners
(
ContextManager
manager
)
{
TracingContext
.
ListenerManager
.
add
(
manager
);
IgnoredTracerContext
.
ListenerManager
.
add
(
manager
);
}
public
AbstractTracerContext
createTraceContext
(
String
operationName
,
boolean
forceSampling
)
{
AbstractTracerContext
context
;
int
suffixIdx
=
operationName
.
lastIndexOf
(
"."
);
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContext.java
浏览文件 @
930e73f1
...
...
@@ -16,17 +16,14 @@
*
*/
package
org.apache.skywalking.apm.agent.core.context
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.NoopSpan
;
import
java.util.*
;
import
org.apache.skywalking.apm.agent.core.context.trace.*
;
/**
* The <code>IgnoredTracerContext</code> represent a context should be ignored.
*
So it just maintains the stack with an
integer depth field.
* The <code>IgnoredTracerContext</code> represent a context should be ignored.
So it just maintains the stack with an
* integer depth field.
*
* All operations through this will be ignored, and keep the memory and gc cost as low as possible.
*
...
...
@@ -88,11 +85,12 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
@Override
public
void
stopSpan
(
AbstractSpan
span
)
{
public
boolean
stopSpan
(
AbstractSpan
span
)
{
stackDepth
--;
if
(
stackDepth
==
0
)
{
ListenerManager
.
notifyFinish
(
this
);
}
return
stackDepth
==
0
;
}
@Override
public
AbstractTracerContext
awaitFinishAsync
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
930e73f1
...
...
@@ -391,7 +391,7 @@ public class TracingContext implements AbstractTracerContext {
* @param span to finish
*/
@Override
public
void
stopSpan
(
AbstractSpan
span
)
{
public
boolean
stopSpan
(
AbstractSpan
span
)
{
AbstractSpan
lastSpan
=
peek
();
if
(
lastSpan
==
span
)
{
if
(
lastSpan
instanceof
AbstractTracingSpan
)
{
...
...
@@ -409,6 +409,8 @@ public class TracingContext implements AbstractTracerContext {
if
(
checkFinishConditions
())
{
finish
();
}
return
activeSpanStack
.
isEmpty
();
}
@Override
public
AbstractTracerContext
awaitFinishAsync
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录