Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
0eb0907d
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
0eb0907d
编写于
11月 12, 2017
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support span amount control mechanism
上级
e8a43a19
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
158 addition
and
11 deletion
+158
-11
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
...org/skywalking/apm/agent/core/context/TracingContext.java
+26
-10
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractNoopSpan.java
...alking/apm/agent/core/context/trace/AbstractNoopSpan.java
+27
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopExitSpan.java
...skywalking/apm/agent/core/context/trace/NoopExitSpan.java
+104
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopSpan.java
...org/skywalking/apm/agent/core/context/trace/NoopSpan.java
+1
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
0eb0907d
...
...
@@ -27,6 +27,7 @@ import org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
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
;
import
org.skywalking.apm.agent.core.context.trace.NoopExitSpan
;
import
org.skywalking.apm.agent.core.context.trace.NoopSpan
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegmentRef
;
...
...
@@ -95,17 +96,28 @@ public class TracingContext implements AbstractTracerContext {
if
(!
span
.
isExit
())
{
throw
new
IllegalStateException
(
"Inject can be done only in Exit Span"
);
}
ExitSpan
exitSpan
=
(
ExitSpan
)
span
;
String
peer
;
int
peerId
;
if
(
span
instanceof
NoopExitSpan
)
{
NoopExitSpan
exitSpan
=
(
NoopExitSpan
)
span
;
peerId
=
exitSpan
.
getPeerId
();
peer
=
exitSpan
.
getPeer
();
}
else
{
ExitSpan
exitSpan
=
(
ExitSpan
)
span
;
peerId
=
exitSpan
.
getPeerId
();
peer
=
exitSpan
.
getPeer
();
}
carrier
.
setTraceSegmentId
(
this
.
segment
.
getTraceSegmentId
());
carrier
.
setSpanId
(
span
.
getSpanId
());
carrier
.
setParentApplicationInstanceId
(
segment
.
getApplicationInstanceId
());
if
(
DictionaryUtil
.
isNull
(
exitSpan
.
getPeerId
()
))
{
carrier
.
setPeerHost
(
exitSpan
.
getPeer
()
);
if
(
DictionaryUtil
.
isNull
(
peerId
))
{
carrier
.
setPeerHost
(
peer
);
}
else
{
carrier
.
setPeerId
(
exitSpan
.
getPeerId
()
);
carrier
.
setPeerId
(
peerId
);
}
List
<
TraceSegmentRef
>
refs
=
this
.
segment
.
getRefs
();
int
operationId
;
...
...
@@ -304,21 +316,21 @@ public class TracingContext implements AbstractTracerContext {
*/
@Override
public
AbstractSpan
createExitSpan
(
final
String
operationName
,
final
String
remotePeer
)
{
if
(
isLimitMechanismWorking
())
{
NoopSpan
span
=
new
NoopSpan
();
return
push
(
span
);
}
AbstractSpan
exitSpan
;
AbstractSpan
parentSpan
=
peek
();
if
(
parentSpan
!=
null
&&
parentSpan
.
isExit
())
{
exitSpan
=
parentSpan
;
}
else
{
final
int
parentSpanId
=
parentSpan
==
null
?
-
1
:
parentSpan
.
getSpanId
();
exitSpan
=
(
Abstract
Tracing
Span
)
DictionaryManager
.
findApplicationCodeSection
()
exitSpan
=
(
AbstractSpan
)
DictionaryManager
.
findApplicationCodeSection
()
.
find
(
remotePeer
).
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
final
int
peerId
)
{
if
(
isLimitMechanismWorking
())
{
return
new
NoopExitSpan
(
peerId
);
}
return
DictionaryManager
.
findOperationNameCodeSection
()
.
findOnly
(
segment
.
getApplicationId
(),
operationName
)
.
doInCondition
(
...
...
@@ -338,6 +350,10 @@ public class TracingContext implements AbstractTracerContext {
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
if
(
isLimitMechanismWorking
())
{
return
new
NoopExitSpan
(
remotePeer
);
}
return
DictionaryManager
.
findOperationNameCodeSection
()
.
findOnly
(
segment
.
getApplicationId
(),
operationName
)
.
doInCondition
(
...
...
@@ -489,6 +505,6 @@ public class TracingContext implements AbstractTracerContext {
}
private
boolean
isLimitMechanismWorking
()
{
return
spanIdGenerator
>
Config
.
Agent
.
SPAN_LIMIT_PER_SEGMENT
;
return
spanIdGenerator
>
=
Config
.
Agent
.
SPAN_LIMIT_PER_SEGMENT
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractNoopSpan.java
0 → 100644
浏览文件 @
0eb0907d
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.context.trace
;
/**
* The <code>AbstractNoopSpan</code> represents a span implementation without any actual operation.
*
* @author zhangxin
*/
public
interface
AbstractNoopSpan
extends
AbstractSpan
{
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopExitSpan.java
0 → 100644
浏览文件 @
0eb0907d
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.context.trace
;
import
java.util.Map
;
import
org.skywalking.apm.network.trace.component.Component
;
public
class
NoopExitSpan
implements
AbstractNoopSpan
{
private
String
peer
;
private
int
peerId
;
public
NoopExitSpan
(
int
peerId
)
{
this
.
peerId
=
peerId
;
}
public
NoopExitSpan
(
String
peer
)
{
this
.
peer
=
peer
;
}
@Override
public
AbstractSpan
setComponent
(
Component
component
)
{
return
this
;
}
@Override
public
AbstractSpan
setComponent
(
String
componentName
)
{
return
this
;
}
@Override
public
AbstractSpan
setLayer
(
SpanLayer
layer
)
{
return
this
;
}
@Override
public
AbstractSpan
tag
(
String
key
,
String
value
)
{
return
this
;
}
@Override
public
AbstractSpan
log
(
Throwable
t
)
{
return
this
;
}
@Override
public
AbstractSpan
errorOccurred
()
{
return
null
;
}
@Override
public
boolean
isEntry
()
{
return
false
;
}
@Override
public
boolean
isExit
()
{
return
true
;
}
@Override
public
AbstractSpan
log
(
long
timestamp
,
Map
<
String
,
?>
event
)
{
return
this
;
}
@Override
public
AbstractSpan
setOperationName
(
String
operationName
)
{
return
this
;
}
@Override
public
AbstractSpan
start
()
{
return
this
;
}
@Override
public
int
getSpanId
()
{
return
0
;
}
@Override
public
int
getOperationId
()
{
return
0
;
}
@Override
public
String
getOperationName
()
{
return
""
;
}
@Override
public
AbstractSpan
setOperationId
(
int
operationId
)
{
return
this
;
}
public
int
getPeerId
()
{
return
peerId
;
}
public
String
getPeer
()
{
return
peer
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopSpan.java
浏览文件 @
0eb0907d
...
...
@@ -29,7 +29,7 @@ import org.skywalking.apm.network.trace.component.Component;
*
* @author wusheng
*/
public
class
NoopSpan
implements
AbstractSpan
{
public
class
NoopSpan
implements
Abstract
Noop
Span
{
public
NoopSpan
()
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录