Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yanghaoyuan.sh
SkyWalking
提交
291e7991
S
SkyWalking
项目概览
yanghaoyuan.sh
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / 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,发现更多精彩内容 >>
提交
291e7991
编写于
7月 24, 2018
作者:
X
Xin,Zhang
提交者:
wu-sheng
7月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cherry-pick from commit
56d7fe4e
上级
a94b5428
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
302 addition
and
71 deletion
+302
-71
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RuntimeContextConfiguration.java
...king/apm/agent/core/conf/RuntimeContextConfiguration.java
+28
-0
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AbstractTracerContext.java
...walking/apm/agent/core/context/AbstractTracerContext.java
+0
-4
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
+7
-5
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContext.java
...ywalking/apm/agent/core/context/IgnoredTracerContext.java
+0
-14
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/RuntimeContext.java
...che/skywalking/apm/agent/core/context/RuntimeContext.java
+37
-1
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/RuntimeContextSnapshot.java
...alking/apm/agent/core/context/RuntimeContextSnapshot.java
+35
-0
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
+0
-13
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
...g/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
+0
-5
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixConcurrencyStrategyInterceptor.java
...gin/hystrix/v1/HystrixConcurrencyStrategyInterceptor.java
+45
-0
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixConcurrencyStrategyWrapper.java
...lugin/hystrix/v1/SWHystrixConcurrencyStrategyWrapper.java
+64
-0
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/define/HystrixPluginsInstrumentation.java
...ugin/hystrix/v1/define/HystrixPluginsInstrumentation.java
+15
-0
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/Constants.java
...ache/skywalking/apm/plugin/jetty/v9/server/Constants.java
+24
-0
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/ForwardInterceptor.java
...alking/apm/plugin/jetty/v9/server/ForwardInterceptor.java
+1
-2
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/HandleInterceptor.java
...walking/apm/plugin/jetty/v9/server/HandleInterceptor.java
+1
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
...in/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
+0
-2
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/Constants.java
...e/skywalking/apm/plugin/spring/mvc/commons/Constants.java
+0
-4
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
...ng/mvc/commons/interceptor/AbstractMethodInterceptor.java
+12
-16
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeForRequestInterceptor.java
.../mvc/commons/interceptor/InvokeForRequestInterceptor.java
+5
-2
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeHandlerMethodInterceptor.java
...c/commons/interceptor/InvokeHandlerMethodInterceptor.java
+2
-0
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/Constants.java
...org/apache/skywalking/apm/plugin/tomcat78x/Constants.java
+24
-0
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/ForwardInterceptor.java
...e/skywalking/apm/plugin/tomcat78x/ForwardInterceptor.java
+1
-3
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
...walking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
+1
-0
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/RuntimeContextConfiguration.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.agent.core.conf
;
public
class
RuntimeContextConfiguration
{
public
static
String
[]
NEED_PROPAGATE_CONTEXT_KEY
=
new
String
[]
{
"SW_REQUEST"
,
"SW_RESPONSE"
};
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/AbstractTracerContext.java
浏览文件 @
291e7991
...
...
@@ -105,8 +105,4 @@ public interface AbstractTracerContext {
*/
void
stopSpan
(
AbstractSpan
span
);
/**
* @return the runtime context from current tracing context.
*/
RuntimeContext
getRuntimeContext
();
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
291e7991
...
...
@@ -42,6 +42,7 @@ import org.apache.skywalking.apm.util.StringUtil;
public
class
ContextManager
implements
TracingContextListener
,
BootService
,
IgnoreTracerContextListener
{
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
>();
private
static
ContextManagerExtendService
EXTEND_SERVICE
;
private
static
AbstractTracerContext
getOrCreate
(
String
operationName
,
boolean
forceSampling
)
{
...
...
@@ -198,11 +199,12 @@ public class ContextManager implements TracingContextListener, BootService, Igno
}
public
static
RuntimeContext
getRuntimeContext
()
{
if
(
isActive
())
{
return
get
().
getRuntimeContext
();
}
else
{
throw
new
IllegalStateException
(
"No active context"
);
RuntimeContext
runtimeContext
=
RUNTIME_CONTEXT
.
get
();
if
(
runtimeContext
==
null
)
{
runtimeContext
=
new
RuntimeContext
(
RUNTIME_CONTEXT
);
RUNTIME_CONTEXT
.
set
(
runtimeContext
);
}
}
return
runtimeContext
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/IgnoredTracerContext.java
浏览文件 @
291e7991
...
...
@@ -37,13 +37,6 @@ public class IgnoredTracerContext implements AbstractTracerContext {
private
int
stackDepth
;
/**
* Runtime context of the ignored context
*
* The context should work even no trace, in order to avoid the unexpected status.
*/
private
RuntimeContext
runtimeContext
;
public
IgnoredTracerContext
()
{
this
.
stackDepth
=
0
;
}
...
...
@@ -102,13 +95,6 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
}
@Override
public
RuntimeContext
getRuntimeContext
()
{
if
(
runtimeContext
==
null
)
{
runtimeContext
=
new
RuntimeContext
();
}
return
runtimeContext
;
}
public
static
class
ListenerManager
{
private
static
List
<
IgnoreTracerContextListener
>
LISTENERS
=
new
LinkedList
<
IgnoreTracerContextListener
>();
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/RuntimeContext.java
浏览文件 @
291e7991
...
...
@@ -18,8 +18,11 @@
package
org.apache.skywalking.apm.agent.core.context
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.skywalking.apm.agent.core.conf.RuntimeContextConfiguration
;
/**
* RuntimeContext is alive during the tracing context.
...
...
@@ -27,11 +30,16 @@ import java.util.concurrent.ConcurrentHashMap;
*
* In most cases, it means it only stays in a single thread for context propagation.
*
* @author wusheng
* @author wusheng
, ascrutae
*/
public
class
RuntimeContext
{
private
final
ThreadLocal
<
RuntimeContext
>
contextThreadLocal
;
private
Map
context
=
new
ConcurrentHashMap
(
0
);
public
RuntimeContext
(
ThreadLocal
<
RuntimeContext
>
contextThreadLocal
)
{
this
.
contextThreadLocal
=
contextThreadLocal
;
}
public
void
put
(
Object
key
,
Object
value
)
{
context
.
put
(
key
,
value
);
}
...
...
@@ -43,4 +51,32 @@ public class RuntimeContext {
public
<
T
>
T
get
(
Object
key
,
Class
<
T
>
type
)
{
return
(
T
)
context
.
get
(
key
);
}
public
void
remove
(
Object
key
)
{
context
.
remove
(
key
);
if
(
context
.
isEmpty
())
{
contextThreadLocal
.
remove
();
}
}
public
RuntimeContextSnapshot
capture
()
{
Map
runtimeContextMap
=
new
HashMap
();
for
(
String
key
:
RuntimeContextConfiguration
.
NEED_PROPAGATE_CONTEXT_KEY
)
{
Object
value
=
this
.
get
(
key
);
if
(
value
!=
null
)
{
runtimeContextMap
.
put
(
key
,
value
);
}
}
return
new
RuntimeContextSnapshot
(
runtimeContextMap
);
}
public
void
accept
(
RuntimeContextSnapshot
snapshot
)
{
Iterator
<
Map
.
Entry
>
iterator
=
snapshot
.
iterator
();
while
(
iterator
.
hasNext
())
{
Map
.
Entry
runtimeContextItem
=
iterator
.
next
();
ContextManager
.
getRuntimeContext
().
put
(
runtimeContextItem
.
getKey
(),
runtimeContextItem
.
getValue
());
}
}
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/RuntimeContextSnapshot.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.agent.core.context
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
RuntimeContextSnapshot
{
private
final
Map
map
;
public
RuntimeContextSnapshot
(
Map
map
)
{
this
.
map
=
map
;
}
public
Iterator
<
Map
.
Entry
>
iterator
()
{
return
map
.
entrySet
().
iterator
();
}
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
291e7991
...
...
@@ -79,11 +79,6 @@ public class TracingContext implements AbstractTracerContext {
*/
private
int
spanIdGenerator
;
/**
* Runtime context of the tracing context
*/
private
RuntimeContext
runtimeContext
;
/**
* Initialize all fields with default value.
*/
...
...
@@ -424,14 +419,6 @@ public class TracingContext implements AbstractTracerContext {
}
}
@Override
public
RuntimeContext
getRuntimeContext
()
{
if
(
runtimeContext
==
null
)
{
runtimeContext
=
new
RuntimeContext
();
}
return
runtimeContext
;
}
/**
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link
* TracingContext.ListenerManager}
...
...
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
浏览文件 @
291e7991
...
...
@@ -18,7 +18,6 @@
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
com.netflix.hystrix.HystrixCommand
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
...
...
@@ -28,8 +27,6 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
hystrix
.
v1
.
Constants
.
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
;
public
class
HystrixCommandRunInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
...
...
@@ -46,8 +43,6 @@ public class HystrixCommandRunInterceptor implements InstanceMethodsAroundInterc
}
// Because of `fall back` method running in other thread. so we need capture concurrent span for tracing.
enhanceRequireObjectCache
.
setContextSnapshot
(
ContextManager
.
capture
());
ContextManager
.
getRuntimeContext
().
put
(
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
,
((
HystrixCommand
)
objInst
).
getProperties
().
executionIsolationStrategy
().
get
().
name
().
toUpperCase
());
}
@Override
...
...
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixConcurrencyStrategyInterceptor.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
public
class
HystrixConcurrencyStrategyInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
return
new
SWHystrixConcurrencyStrategyWrapper
((
HystrixConcurrencyStrategy
)
ret
);
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixConcurrencyStrategyWrapper.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy
;
import
java.util.concurrent.Callable
;
import
org.apache.skywalking.apm.agent.core.conf.RuntimeContextConfiguration
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.RuntimeContextSnapshot
;
public
class
SWHystrixConcurrencyStrategyWrapper
extends
HystrixConcurrencyStrategy
{
private
final
HystrixConcurrencyStrategy
delegate
;
public
SWHystrixConcurrencyStrategyWrapper
(
HystrixConcurrencyStrategy
delegate
)
{
this
.
delegate
=
delegate
;
}
@Override
public
<
T
>
Callable
<
T
>
wrapCallable
(
Callable
<
T
>
callable
)
{
return
new
WrappedCallable
<
T
>(
ContextManager
.
getRuntimeContext
().
capture
(),
super
.
wrapCallable
(
callable
));
}
static
class
WrappedCallable
<
T
>
implements
Callable
<
T
>
{
private
final
RuntimeContextSnapshot
contextSnapshot
;
private
final
Callable
<
T
>
target
;
WrappedCallable
(
RuntimeContextSnapshot
contextSnapshot
,
Callable
<
T
>
target
)
{
this
.
contextSnapshot
=
contextSnapshot
;
this
.
target
=
target
;
}
@Override
public
T
call
()
throws
Exception
{
try
{
ContextManager
.
getRuntimeContext
().
accept
(
contextSnapshot
);
return
target
.
call
();
}
finally
{
for
(
String
key
:
RuntimeContextConfiguration
.
NEED_PROPAGATE_CONTEXT_KEY
)
{
ContextManager
.
getRuntimeContext
().
remove
(
key
);
}
}
}
}
}
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/define/HystrixPluginsInstrumentation.java
浏览文件 @
291e7991
...
...
@@ -32,6 +32,8 @@ public class HystrixPluginsInstrumentation extends ClassInstanceMethodsEnhancePl
public
static
final
String
INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.hystrix.v1.HystrixPluginsInterceptor"
;
public
static
final
String
ENHANCE_METHOD
=
"getCommandExecutionHook"
;
public
static
final
String
GET_CONCURRENCY_STRATEGY_METHOD
=
"getConcurrencyStrategy"
;
public
static
final
String
GET_CONCURRENCY_STRATEGY_INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.hystrix.v1.HystrixConcurrencyStrategyInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"com.netflix.hystrix.strategy.HystrixPlugins"
;
@Override
...
...
@@ -51,6 +53,19 @@ public class HystrixPluginsInstrumentation extends ClassInstanceMethodsEnhancePl
return
INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
GET_CONCURRENCY_STRATEGY_METHOD
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
GET_CONCURRENCY_STRATEGY_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
...
...
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/Constants.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.plugin.jetty.v9.server
;
public
class
Constants
{
public
static
final
String
FORWARD_REQUEST_FLAG
=
"SW_FORWARD_REQUEST_FLAG"
;
}
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/ForwardInterceptor.java
浏览文件 @
291e7991
...
...
@@ -30,7 +30,6 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
public
class
ForwardInterceptor
implements
InstanceMethodsAroundInterceptor
,
InstanceConstructorInterceptor
{
private
static
final
String
FORWARD_REQUEST_FLAG
=
"SW_FORWARD_REQUEST_FLAG"
;
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
...
...
@@ -40,7 +39,7 @@ public class ForwardInterceptor implements InstanceMethodsAroundInterceptor, Ins
Map
<
String
,
String
>
eventMap
=
new
HashMap
<
String
,
String
>();
eventMap
.
put
(
"forward-url"
,
(
String
)
objInst
.
getSkyWalkingDynamicField
());
abstractTracingSpan
.
log
(
System
.
currentTimeMillis
(),
eventMap
);
ContextManager
.
getRuntimeContext
().
put
(
FORWARD_REQUEST_FLAG
,
true
);
ContextManager
.
getRuntimeContext
().
put
(
Constants
.
FORWARD_REQUEST_FLAG
,
true
);
}
}
...
...
apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/HandleInterceptor.java
浏览文件 @
291e7991
...
...
@@ -67,6 +67,7 @@ public class HandleInterceptor implements InstanceMethodsAroundInterceptor {
Tags
.
STATUS_CODE
.
set
(
span
,
Integer
.
toString
(
servletResponse
.
getStatus
()));
}
ContextManager
.
stopSpan
();
ContextManager
.
getRuntimeContext
().
remove
(
Constants
.
FORWARD_REQUEST_FLAG
);
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
浏览文件 @
291e7991
...
...
@@ -174,9 +174,7 @@ public class RequestMappingMethodInterceptorTest {
@Override
public
Object
getSkyWalkingDynamicField
()
{
value
.
setPathMappingCache
(
new
PathMappingCache
(
"/test"
));
return
value
;
}
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/Constants.java
浏览文件 @
291e7991
...
...
@@ -32,13 +32,9 @@ public class Constants {
public
static
final
String
REST_MAPPING_METHOD_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.RestMappingMethodInterceptor"
;
public
static
final
String
HYSTRIX_COMMAND_ANNOTATION
=
"com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand"
;
public
static
final
String
REQUEST_KEY_IN_RUNTIME_CONTEXT
=
"SW_REQUEST"
;
public
static
final
String
RESPONSE_KEY_IN_RUNTIME_CONTEXT
=
"SW_RESPONSE"
;
public
static
final
String
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
=
"ISOLATE_STRATEGY"
;
public
static
final
String
FORWARD_REQUEST_FLAG
=
"SW_FORWARD_REQUEST_FLAG"
;
}
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
浏览文件 @
291e7991
...
...
@@ -34,7 +34,6 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import
org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
FORWARD_REQUEST_FLAG
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
REQUEST_KEY_IN_RUNTIME_CONTEXT
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
RESPONSE_KEY_IN_RUNTIME_CONTEXT
;
...
...
@@ -65,12 +64,8 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
requestURL
=
pathMappingCache
.
findPathMapping
(
method
);
}
String
hystrixIsolateStrategy
=
(
String
)
ContextManager
.
getRuntimeContext
().
get
(
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
);
HttpServletRequest
request
=
(
HttpServletRequest
)
ContextManager
.
getRuntimeContext
().
get
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
if
(
hystrixIsolateStrategy
!=
null
)
{
ContextManager
.
createLocalSpan
(
requestURL
);
}
else
if
(
request
!=
null
)
{
if
(
request
!=
null
)
{
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
...
...
@@ -98,18 +93,19 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
return
ret
;
}
String
hystrixIsolateStrategy
=
(
String
)
ContextManager
.
getRuntimeContext
().
get
(
ISOLATE_STRATEGY_KEY_IN_RUNNING_CONTEXT
);
HttpServletResponse
response
=
(
HttpServletResponse
)
ContextManager
.
getRuntimeContext
().
get
(
RESPONSE_KEY_IN_RUNTIME_CONTEXT
);
if
(
hystrixIsolateStrategy
!=
null
)
{
ContextManager
.
stop
Span
();
}
else
if
(
response
!=
null
)
{
AbstractSpan
span
=
ContextManager
.
activeSpan
();
if
(
response
.
getStatus
()
>=
400
)
{
span
.
errorOccurred
();
Tags
.
STATUS_CODE
.
set
(
span
,
Integer
.
toString
(
response
.
getStatus
())
);
try
{
if
(
response
!=
null
)
{
AbstractSpan
span
=
ContextManager
.
active
Span
();
if
(
response
.
getStatus
()
>=
400
)
{
span
.
errorOccurred
();
Tags
.
STATUS_CODE
.
set
(
span
,
Integer
.
toString
(
response
.
getStatus
()));
}
ContextManager
.
stopSpan
(
);
}
ContextManager
.
stopSpan
();
}
finally
{
ContextManager
.
getRuntimeContext
().
remove
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
ContextManager
.
getRuntimeContext
().
remove
(
RESPONSE_KEY_IN_RUNTIME_CONTEXT
);
}
return
ret
;
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeForRequestInterceptor.java
浏览文件 @
291e7991
...
...
@@ -19,14 +19,14 @@
package
org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.springframework.web.context.request.NativeWebRequest
;
import
java.lang.reflect.Method
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
REQUEST_KEY_IN_RUNTIME_CONTEXT
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
mvc
.
commons
.
Constants
.
RESPONSE_KEY_IN_RUNTIME_CONTEXT
;
/**
...
...
@@ -45,6 +45,9 @@ public class InvokeForRequestInterceptor implements InstanceMethodsAroundInterce
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
getRuntimeContext
().
remove
(
RESPONSE_KEY_IN_RUNTIME_CONTEXT
);
// clear request in this method
ContextManager
.
getRuntimeContext
().
remove
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/InvokeHandlerMethodInterceptor.java
浏览文件 @
291e7991
...
...
@@ -40,6 +40,8 @@ public class InvokeHandlerMethodInterceptor implements InstanceMethodsAroundInte
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
getRuntimeContext
().
remove
(
RESPONSE_KEY_IN_RUNTIME_CONTEXT
);
ContextManager
.
getRuntimeContext
().
remove
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/Constants.java
0 → 100644
浏览文件 @
291e7991
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*
*/
package
org.apache.skywalking.apm.plugin.tomcat78x
;
public
class
Constants
{
public
static
final
String
FORWARD_REQUEST_FLAG
=
"SW_FORWARD_REQUEST_FLAG"
;
}
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/ForwardInterceptor.java
浏览文件 @
291e7991
...
...
@@ -31,8 +31,6 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
public
class
ForwardInterceptor
implements
InstanceMethodsAroundInterceptor
,
InstanceConstructorInterceptor
{
private
static
final
String
FORWARD_REQUEST_FLAG
=
"SW_FORWARD_REQUEST_FLAG"
;
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
...
...
@@ -41,7 +39,7 @@ public class ForwardInterceptor implements InstanceMethodsAroundInterceptor, Ins
Map
<
String
,
String
>
eventMap
=
new
HashMap
<
String
,
String
>();
eventMap
.
put
(
"forward-url"
,
(
String
)
objInst
.
getSkyWalkingDynamicField
());
abstractTracingSpan
.
log
(
System
.
currentTimeMillis
(),
eventMap
);
ContextManager
.
getRuntimeContext
().
put
(
FORWARD_REQUEST_FLAG
,
true
);
ContextManager
.
getRuntimeContext
().
put
(
Constants
.
FORWARD_REQUEST_FLAG
,
true
);
}
}
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
浏览文件 @
291e7991
...
...
@@ -81,6 +81,7 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
Tags
.
STATUS_CODE
.
set
(
span
,
Integer
.
toString
(
response
.
getStatus
()));
}
ContextManager
.
stopSpan
();
ContextManager
.
getRuntimeContext
().
remove
(
Constants
.
FORWARD_REQUEST_FLAG
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录