Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
cc2163b7
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,发现更多精彩内容 >>
提交
cc2163b7
编写于
9月 19, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix compile issues.
上级
3e2e294d
变更
24
显示空白变更内容
内联
并排
Showing
24 changed file
with
143 addition
and
187 deletion
+143
-187
apm-application-toolkit/apm-toolkit-opentracing/src/main/java/org/skywalking/apm/toolkit/opentracing/SkywalkingTracer.java
.../skywalking/apm/toolkit/opentracing/SkywalkingTracer.java
+3
-71
apm-application-toolkit/apm-toolkit-opentracing/src/main/java/org/skywalking/apm/toolkit/opentracing/TextMapContext.java
...rg/skywalking/apm/toolkit/opentracing/TextMapContext.java
+2
-7
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/CarrierItemHead.java
...rg/skywalking/apm/agent/core/context/CarrierItemHead.java
+10
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
...org/skywalking/apm/agent/core/context/ContextCarrier.java
+3
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ids/ID.java
...in/java/org/skywalking/apm/agent/core/context/ids/ID.java
+19
-8
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java
...skywalking/apm/agent/core/context/ContextManagerTest.java
+2
-2
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInterceptor.java
...ava/org/skywalking/apm/plugin/dubbo/DubboInterceptor.java
+6
-6
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
...org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
+2
-39
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/RequestParamForTestBelow283.java
...walking/apm/plugin/dubbo/RequestParamForTestBelow283.java
+0
-10
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
...pm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
...pm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptor.java
...skywalking/apm/plugin/motan/MotanConsumerInterceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptor.java
...skywalking/apm/plugin/motan/MotanProviderInterceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java
.../skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/ResinV3Interceptor.java
...rg/skywalking/apm/plugin/resin/v3/ResinV3Interceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/ResinV4Interceptor.java
...rg/skywalking/apm/plugin/resin/v4/ResinV4Interceptor.java
+3
-3
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/ControllerServiceMethodInterceptor.java
...plugin/spring/mvc/ControllerServiceMethodInterceptor.java
+9
-5
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java
...gin/spring/resttemplate/async/RestExecuteInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java
...ugin/spring/resttemplate/sync/RestExecuteInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/sync/RestRequestInterceptor.java
...ugin/spring/resttemplate/sync/RestRequestInterceptor.java
+8
-2
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/springframework/http/client/RestRequestInterceptor.java
...g/springframework/http/client/RestRequestInterceptor.java
+9
-2
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
...walking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
+3
-3
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerExtractInterceptor.java
...pentracing/tracer/SkywalkingTracerExtractInterceptor.java
+26
-5
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerInjectInterceptor.java
...opentracing/tracer/SkywalkingTracerInjectInterceptor.java
+18
-3
未找到文件。
apm-application-toolkit/apm-toolkit-opentracing/src/main/java/org/skywalking/apm/toolkit/opentracing/SkywalkingTracer.java
浏览文件 @
cc2163b7
...
...
@@ -5,64 +5,26 @@ import io.opentracing.Span;
import
io.opentracing.SpanContext
;
import
io.opentracing.Tracer
;
import
io.opentracing.propagation.Format
;
import
io.opentracing.propagation.TextMap
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* @author wusheng
*/
public
class
SkywalkingTracer
implements
Tracer
{
private
static
String
TRACE_HEAD_NAME
=
"sw3"
;
@NeedSnifferActivation
(
"1. ContextManager#inject"
+
"2. ContextCarrier#serialize"
)
private
String
inject
()
{
return
null
;
}
@NeedSnifferActivation
(
"1. ContextCarrier#deserialize"
+
"2. ContextManager#extract"
)
private
void
extract
(
String
carrier
)
{
}
@Override
public
SpanBuilder
buildSpan
(
String
operationName
)
{
return
new
SkywalkingSpanBuilder
(
operationName
);
}
@NeedSnifferActivation
@Override
public
<
C
>
void
inject
(
SpanContext
spanContext
,
Format
<
C
>
format
,
C
carrier
)
{
if
(
Format
.
Builtin
.
TEXT_MAP
.
equals
(
format
)
||
Format
.
Builtin
.
HTTP_HEADERS
.
equals
(
format
))
{
((
TextMap
)
carrier
).
put
(
TRACE_HEAD_NAME
,
inject
());
}
else
if
(
Format
.
Builtin
.
BINARY
.
equals
(
format
))
{
byte
[]
key
=
TRACE_HEAD_NAME
.
getBytes
(
ByteBufferContext
.
CHARSET
);
byte
[]
value
=
inject
().
getBytes
(
ByteBufferContext
.
CHARSET
);
((
ByteBuffer
)
carrier
).
put
(
key
);
((
ByteBuffer
)
carrier
).
putInt
(
value
.
length
);
((
ByteBuffer
)
carrier
).
put
(
value
);
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported format: "
+
format
);
}
}
@NeedSnifferActivation
@Override
public
<
C
>
SpanContext
extract
(
Format
<
C
>
format
,
C
carrier
)
{
if
(
Format
.
Builtin
.
TEXT_MAP
.
equals
(
format
)
||
Format
.
Builtin
.
HTTP_HEADERS
.
equals
(
format
))
{
TextMap
textMapCarrier
=
(
TextMap
)
carrier
;
extract
(
fetchContextData
(
textMapCarrier
));
return
new
TextMapContext
(
textMapCarrier
);
}
else
if
(
Format
.
Builtin
.
BINARY
.
equals
(
format
))
{
ByteBuffer
byteBufferCarrier
=
(
ByteBuffer
)
carrier
;
extract
(
fetchContextData
(
byteBufferCarrier
));
return
new
ByteBufferContext
((
ByteBuffer
)
carrier
);
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported format: "
+
format
);
}
return
new
TextMapContext
();
}
@Override
...
...
@@ -78,34 +40,4 @@ public class SkywalkingTracer implements Tracer {
throw
new
IllegalArgumentException
(
"span must be a type of SkywalkingSpan"
);
}
}
private
String
fetchContextData
(
TextMap
textMap
)
{
Iterator
<
Map
.
Entry
<
String
,
String
>>
iterator
=
textMap
.
iterator
();
while
(
iterator
.
hasNext
())
{
Map
.
Entry
<
String
,
String
>
entry
=
iterator
.
next
();
if
(
TRACE_HEAD_NAME
.
equals
(
entry
.
getKey
()))
{
return
entry
.
getValue
();
}
}
return
null
;
}
private
String
fetchContextData
(
ByteBuffer
byteBuffer
)
{
String
contextDataStr
=
new
String
(
byteBuffer
.
array
(),
Charset
.
forName
(
"UTF-8"
));
int
index
=
contextDataStr
.
indexOf
(
TRACE_HEAD_NAME
);
if
(
index
==
-
1
)
{
return
null
;
}
try
{
byteBuffer
.
position
(
index
+
TRACE_HEAD_NAME
.
getBytes
().
length
);
byte
[]
contextDataBytes
=
new
byte
[
byteBuffer
.
getInt
()];
byteBuffer
.
get
(
contextDataBytes
);
return
new
String
(
contextDataBytes
,
Charset
.
forName
(
"UTF-8"
));
}
catch
(
Exception
e
)
{
return
null
;
}
}
}
apm-application-toolkit/apm-toolkit-opentracing/src/main/java/org/skywalking/apm/toolkit/opentracing/TextMapContext.java
浏览文件 @
cc2163b7
package
org.skywalking.apm.toolkit.opentracing
;
import
io.opentracing.SpanContext
;
import
io.opentracing.propagation.TextMap
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -10,14 +8,11 @@ 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
;
public
TextMapContext
()
{
}
@Override
public
Iterable
<
Map
.
Entry
<
String
,
String
>>
baggageItems
()
{
return
new
HashMap
<
String
,
String
>().
entrySet
();
return
new
HashMap
<
String
,
String
>(
0
).
entrySet
();
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/CarrierItemHead.java
0 → 100644
浏览文件 @
cc2163b7
package
org.skywalking.apm.agent.core.context
;
/**
* @author wusheng
*/
public
class
CarrierItemHead
extends
CarrierItem
{
public
CarrierItemHead
(
CarrierItem
next
)
{
super
(
""
,
""
,
next
);
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
浏览文件 @
cc2163b7
...
...
@@ -61,7 +61,8 @@ public class ContextCarrier implements Serializable {
public
CarrierItem
items
()
{
SW3CarrierItem
carrierItem
=
new
SW3CarrierItem
(
this
,
null
);
return
carrierItem
;
CarrierItemHead
head
=
new
CarrierItemHead
(
carrierItem
);
return
head
;
}
/**
...
...
@@ -119,6 +120,7 @@ public class ContextCarrier implements Serializable {
*/
public
boolean
isValid
()
{
return
traceSegmentId
!=
null
&&
traceSegmentId
.
isValid
()
&&
getSpanId
()
>
-
1
&&
parentApplicationInstanceId
!=
DictionaryUtil
.
nullValue
()
&&
entryApplicationInstanceId
!=
DictionaryUtil
.
nullValue
()
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ids/ID.java
浏览文件 @
cc2163b7
...
...
@@ -10,18 +10,21 @@ public class ID {
private
long
part2
;
private
long
part3
;
private
String
encoding
;
private
boolean
isValid
;
public
ID
(
long
part1
,
long
part2
,
long
part3
)
{
this
.
part1
=
part1
;
this
.
part2
=
part2
;
this
.
part3
=
part3
;
this
.
encoding
=
null
;
this
.
isValid
=
true
;
}
public
ID
(
String
encodingString
)
{
String
[]
idParts
=
encodingString
.
split
(
"."
,
3
);
int
index
=
0
;
String
[]
idParts
=
encodingString
.
split
(
"
\\
."
,
3
);
this
.
isValid
=
true
;
for
(
int
part
=
0
;
part
<
3
;
part
++)
{
try
{
if
(
part
==
0
)
{
part1
=
Long
.
parseLong
(
idParts
[
part
]);
}
else
if
(
part
==
1
)
{
...
...
@@ -29,6 +32,10 @@ public class ID {
}
else
{
part3
=
Long
.
parseLong
(
idParts
[
part
]);
}
}
catch
(
NumberFormatException
e
)
{
this
.
isValid
=
false
;
break
;
}
}
}
...
...
@@ -66,6 +73,10 @@ public class ID {
return
result
;
}
public
boolean
isValid
()
{
return
isValid
;
}
public
UniqueId
transform
()
{
return
UniqueId
.
newBuilder
().
addIdParts
(
part1
).
addIdParts
(
part2
).
addIdParts
(
part3
).
build
();
}
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java
浏览文件 @
cc2163b7
...
...
@@ -79,7 +79,7 @@ public class ContextManagerTest {
@Test
public
void
createMultipleEntrySpan
()
{
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
"
#AQA*#AQA*4WcWe0tQNQA*
|1|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
"
1.2343.234234234
|1|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
assertTrue
(
contextCarrier
.
isValid
());
AbstractSpan
firstEntrySpan
=
ContextManager
.
createEntrySpan
(
"/testFirstEntry"
,
contextCarrier
);
...
...
@@ -202,7 +202,7 @@ public class ContextManagerTest {
@Test
public
void
testTransform
()
throws
InvalidProtocolBufferException
{
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
"
#AQA*#AQA*4WcWe0tQNQA*
|3|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
"
1.234.1983829
|3|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
assertTrue
(
contextCarrier
.
isValid
());
AbstractSpan
firstEntrySpan
=
ContextManager
.
createEntrySpan
(
"/testFirstEntry"
,
contextCarrier
);
...
...
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -50,16 +50,16 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
span
=
ContextManager
.
createExitSpan
(
generateOperationName
(
requestURL
,
invocation
),
contextCarrier
,
host
+
":"
+
port
);
//invocation.getAttachments().put("contextData", contextDataStr);
//@see https://github.com/alibaba/dubbo/blob/dubbo-2.5.3/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java#L154-L161
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
rpcContext
.
getAttachments
().
put
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
else
{
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
rpcContext
.
getAttachment
(
next
.
getHeadKey
()));
}
...
...
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
浏览文件 @
cc2163b7
...
...
@@ -13,11 +13,9 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.powermock.api.mockito.PowerMockito
;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.skywalking.apm.agent.core.context.trace.LogDataEntity
;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
...
...
@@ -26,7 +24,6 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
import
org.skywalking.apm.agent.core.context.util.KeyValuePair
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.agent.test.helper.FieldSetter
;
import
org.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.skywalking.apm.agent.test.helper.SegmentRefHelper
;
import
org.skywalking.apm.agent.test.helper.SpanHelper
;
...
...
@@ -34,7 +31,6 @@ import org.skywalking.apm.agent.test.tools.AgentServiceRule;
import
org.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.skywalking.apm.plugin.dubbox.BugFixActive
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertNull
;
...
...
@@ -44,7 +40,6 @@ import static org.powermock.api.mockito.PowerMockito.when;
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
@PrepareForTest
({
RpcContext
.
class
,
BugFixActive
.
class
})
public
class
DubboInterceptorTest
{
@SegmentStoragePoint
...
...
@@ -58,7 +53,6 @@ public class DubboInterceptorTest {
private
DubboInterceptor
dubboInterceptor
;
private
RequestParamForTestBelow283
testParam
;
@Mock
private
RpcContext
rpcContext
;
@Mock
...
...
@@ -76,39 +70,20 @@ public class DubboInterceptorTest {
@Before
public
void
setUp
()
throws
Exception
{
dubboInterceptor
=
new
DubboInterceptor
();
testParam
=
new
RequestParamForTestBelow283
();
PowerMockito
.
mockStatic
(
RpcContext
.
class
);
when
(
invoker
.
getUrl
()).
thenReturn
(
URL
.
valueOf
(
"dubbo://127.0.0.1:20880/org.skywalking.apm.test.TestDubboService"
));
when
(
invocation
.
getMethodName
()).
thenReturn
(
"test"
);
when
(
invocation
.
getParameterTypes
()).
thenReturn
(
new
Class
[]
{
String
.
class
});
when
(
invocation
.
getArguments
()).
thenReturn
(
new
Object
[]
{
testParam
});
when
(
invocation
.
getArguments
()).
thenReturn
(
new
Object
[]
{
"abc"
});
PowerMockito
.
when
(
RpcContext
.
getContext
()).
thenReturn
(
rpcContext
);
when
(
rpcContext
.
isConsumerSide
()).
thenReturn
(
true
);
allArguments
=
new
Object
[]
{
invoker
,
invocation
};
argumentTypes
=
new
Class
[]
{
invoker
.
getClass
(),
invocation
.
getClass
()};
Config
.
Agent
.
APPLICATION_CODE
=
"DubboTestCases-APP"
;
FieldSetter
.
setStaticValue
(
BugFixActive
.
class
,
"ACTIVE"
,
false
);
}
@Test
public
void
testConsumerBelow283
()
throws
Throwable
{
BugFixActive
.
active
();
dubboInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
methodInterceptResult
);
dubboInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
result
);
assertThat
(
segmentStorage
.
getTraceSegments
().
size
(),
is
(
1
));
TraceSegment
traceSegment
=
segmentStorage
.
getTraceSegments
().
get
(
0
);
assertThat
(
SegmentHelper
.
getSpans
(
traceSegment
).
size
(),
is
(
1
));
assertConsumerSpan
(
SegmentHelper
.
getSpans
(
traceSegment
).
get
(
0
));
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
contextCarrier
.
deserialize
(
testParam
.
getTraceContext
());
assertTrue
(
contextCarrier
.
isValid
());
}
@Test
public
void
testConsumerWithAttachment
()
throws
Throwable
{
...
...
@@ -147,25 +122,13 @@ public class DubboInterceptorTest {
@Test
public
void
testProviderWithAttachment
()
throws
Throwable
{
when
(
rpcContext
.
isConsumerSide
()).
thenReturn
(
false
);
when
(
rpcContext
.
getAttachment
(
Config
.
Plugin
.
Propagation
.
HEADER_NAME
)).
thenReturn
(
"#AQA*#AQA*4WcWe0tQNQA*
|3|1|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
when
(
rpcContext
.
getAttachment
(
"sw3"
)).
thenReturn
(
"1.323.4433
|3|1|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
dubboInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
methodInterceptResult
);
dubboInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
result
);
assertProvider
();
}
@Test
public
void
testProviderBelow283
()
throws
Throwable
{
when
(
rpcContext
.
isConsumerSide
()).
thenReturn
(
false
);
FieldSetter
.
setStaticValue
(
BugFixActive
.
class
,
"ACTIVE"
,
true
);
testParam
.
setTraceContext
(
"#AQA*#AQA*4WcWe0tQNQA*|3|1|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"
);
dubboInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
methodInterceptResult
);
dubboInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
allArguments
,
argumentTypes
,
result
);
assertProvider
();
}
private
void
assertConsumerTraceSegmentInErrorCase
(
TraceSegment
traceSegment
)
{
...
...
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/RequestParamForTestBelow283.java
已删除
100644 → 0
浏览文件 @
3e2e294d
package
org.skywalking.apm.plugin.dubbo
;
import
org.skywalking.apm.plugin.dubbox.SWBaseBean
;
/**
* {@link RequestParamForTestBelow283} store context data for test.
*/
public
class
RequestParamForTestBelow283
extends
SWBaseBean
{
}
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -61,9 +61,9 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
headersField
.
setAccessible
(
true
);
Map
<
String
,
Collection
<
String
>>
headers
=
new
LinkedHashMap
<
String
,
Collection
<
String
>>();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
List
<
String
>
contextCollection
=
new
LinkedList
<
String
>();
contextCollection
.
add
(
next
.
getHeadValue
());
headers
.
put
(
next
.
getHeadKey
(),
contextCollection
);
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -42,9 +42,9 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
Tags
.
HTTP
.
METHOD
.
set
(
span
,
httpRequest
.
getRequestLine
().
getMethod
());
SpanLayer
.
asHttp
(
span
);
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
httpRequest
.
setHeader
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -42,9 +42,9 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
span
.
setComponent
(
ComponentsDefine
.
MOTAN
);
Tags
.
URL
.
set
(
span
,
url
.
getIdentity
());
SpanLayer
.
asRPCFramework
(
span
);
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
request
.
setAttachment
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -28,9 +28,9 @@ public class MotanProviderInterceptor implements InstanceMethodsAroundIntercepto
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
Request
request
=
(
Request
)
allArguments
[
0
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
request
.
getAttachments
().
get
(
next
.
getHeadKey
()));
}
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -67,9 +67,9 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In
headersField
.
setAccessible
(
true
);
Headers
.
Builder
headerBuilder
=
request
.
headers
().
newBuilder
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headerBuilder
.
add
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
headersField
.
set
(
request
,
headerBuilder
.
build
());
...
...
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/ResinV3Interceptor.java
浏览文件 @
cc2163b7
...
...
@@ -26,9 +26,9 @@ public class ResinV3Interceptor implements InstanceMethodsAroundInterceptor {
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
CauchoRequest
request
=
(
CauchoRequest
)
allArguments
[
0
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
}
...
...
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/ResinV4Interceptor.java
浏览文件 @
cc2163b7
...
...
@@ -23,9 +23,9 @@ public class ResinV4Interceptor implements InstanceMethodsAroundInterceptor {
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
CauchoRequest
request
=
(
CauchoRequest
)
allArguments
[
0
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
}
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
request
.
getPageURI
(),
contextCarrier
);
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/ControllerServiceMethodInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -3,7 +3,7 @@ package org.skywalking.apm.plugin.spring.mvc;
import
java.lang.reflect.Method
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.skywalking.apm.agent.core.con
f.Config
;
import
org.skywalking.apm.agent.core.con
text.CarrierItem
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.context.tag.Tags
;
...
...
@@ -19,8 +19,6 @@ import org.springframework.web.context.request.ServletRequestAttributes;
/**
* The <code>ControllerServiceMethodInterceptor</code> only use the first mapping value.
*
* @See {@link ControllerConstructorInterceptor} to explain why we are doing this.
*/
public
class
ControllerServiceMethodInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
...
...
@@ -40,8 +38,14 @@ public class ControllerServiceMethodInterceptor implements InstanceMethodsAround
}
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
String
tracingHeaderValue
=
request
.
getHeader
(
Config
.
Plugin
.
Propagation
.
HEADER_NAME
);
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
tracingHeaderValue
);
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
}
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
requestURL
,
contextCarrier
);
Tags
.
URL
.
set
(
span
,
request
.
getRequestURL
().
toString
());
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
getMethod
());
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -30,7 +30,7 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor
SpanLayer
.
asHttp
(
span
);
Object
[]
cacheValues
=
new
Object
[
3
];
cacheValues
[
0
]
=
requestURL
;
cacheValues
[
1
]
=
contextCarrier
.
serialize
()
;
cacheValues
[
1
]
=
contextCarrier
;
objInst
.
setSkyWalkingDynamicField
(
cacheValues
);
}
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -29,7 +29,7 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor
Tags
.
HTTP
.
METHOD
.
set
(
span
,
httpMethod
.
toString
());
SpanLayer
.
asHttp
(
span
);
objInst
.
setSkyWalkingDynamicField
(
contextCarrier
.
serialize
()
);
objInst
.
setSkyWalkingDynamicField
(
contextCarrier
);
}
@Override
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/sync/RestRequestInterceptor.java
浏览文件 @
cc2163b7
package
org.skywalking.apm.plugin.spring.resttemplate.sync
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.CarrierItem
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
@@ -22,7 +23,12 @@ public class RestRequestInterceptor implements InstanceMethodsAroundInterceptor
ClientHttpRequest
clientHttpRequest
=
(
ClientHttpRequest
)
ret
;
if
(
clientHttpRequest
instanceof
AbstractClientHttpRequest
)
{
AbstractClientHttpRequest
httpRequest
=
(
AbstractClientHttpRequest
)
clientHttpRequest
;
httpRequest
.
getHeaders
().
set
(
Config
.
Plugin
.
Propagation
.
HEADER_NAME
,
String
.
valueOf
(
objInst
.
getSkyWalkingDynamicField
()));
ContextCarrier
contextCarrier
=
(
ContextCarrier
)
objInst
.
getSkyWalkingDynamicField
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
httpRequest
.
getHeaders
().
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/springframework/http/client/RestRequestInterceptor.java
浏览文件 @
cc2163b7
package
org.springframework.http.client
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.CarrierItem
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
@@ -19,7 +20,13 @@ public class RestRequestInterceptor implements InstanceMethodsAroundInterceptor
Object
ret
)
throws
Throwable
{
AbstractAsyncClientHttpRequest
clientHttpRequest
=
(
AbstractAsyncClientHttpRequest
)
ret
;
if
(
ret
!=
null
)
{
clientHttpRequest
.
getHeaders
().
set
(
Config
.
Plugin
.
Propagation
.
HEADER_NAME
,
String
.
valueOf
(((
Object
[])
objInst
.
getSkyWalkingDynamicField
())[
1
]));
Object
[]
cacheValues
=
(
Object
[])
objInst
.
getSkyWalkingDynamicField
();
ContextCarrier
contextCarrier
=
(
ContextCarrier
)
cacheValues
[
1
];
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
clientHttpRequest
.
getHeaders
().
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
浏览文件 @
cc2163b7
...
...
@@ -38,9 +38,9 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
HttpServletRequest
request
=
(
HttpServletRequest
)
allArguments
[
0
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
items
=
contextCarrier
.
items
();
while
(
items
.
hasNext
())
{
CarrierItem
next
=
items
.
next
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
}
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerExtractInterceptor.java
浏览文件 @
cc2163b7
package
org.skywalking.apm.toolkit.activation.opentracing.tracer
;
import
io.opentracing.propagation.Format
;
import
io.opentracing.propagation.TextMap
;
import
java.lang.reflect.Method
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.skywalking.apm.agent.core.context.CarrierItem
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.toolkit.opentracing.TextMapContext
;
public
class
SkywalkingTracerExtractInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
...
...
@@ -17,10 +22,26 @@ public class SkywalkingTracerExtractInterceptor implements InstanceMethodsAround
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
String
carrier
=
(
String
)
allArguments
[
0
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
().
deserialize
(
carrier
);
ContextManager
.
extract
(
contextCarrier
);
return
ret
;
Format
format
=
(
Format
)
allArguments
[
0
];
if
(
Format
.
Builtin
.
TEXT_MAP
.
equals
(
format
)
||
Format
.
Builtin
.
HTTP_HEADERS
.
equals
(
format
))
{
TextMap
textMapCarrier
=
(
TextMap
)
allArguments
[
1
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
Iterator
<
Map
.
Entry
<
String
,
String
>>
iterator
=
textMapCarrier
.
iterator
();
while
(
iterator
.
hasNext
())
{
Map
.
Entry
<
String
,
String
>
entry
=
iterator
.
next
();
if
(
next
.
getHeadKey
().
equals
(
entry
.
getKey
()))
{
next
.
setHeadValue
(
entry
.
getValue
());
break
;
}
}
}
}
return
new
TextMapContext
();
}
@Override
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerInjectInterceptor.java
浏览文件 @
cc2163b7
package
org.skywalking.apm.toolkit.activation.opentracing.tracer
;
import
io.opentracing.propagation.Format
;
import
io.opentracing.propagation.TextMap
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.context.CarrierItem
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
...
...
@@ -17,9 +20,21 @@ public class SkywalkingTracerInjectInterceptor implements InstanceMethodsAroundI
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
Format
format
=
(
Format
)
allArguments
[
1
];
if
(
Format
.
Builtin
.
TEXT_MAP
.
equals
(
format
)
||
Format
.
Builtin
.
HTTP_HEADERS
.
equals
(
format
))
{
TextMap
carrier
=
(
TextMap
)
allArguments
[
2
];
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
ContextManager
.
inject
(
contextCarrier
);
return
contextCarrier
.
serialize
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
carrier
.
put
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
else
{
//Don't support other format yet.
}
return
null
;
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录