Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
月轩居士
SkyWalking
提交
62f21330
S
SkyWalking
项目概览
月轩居士
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
4
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,发现更多精彩内容 >>
提交
62f21330
编写于
3月 12, 2019
作者:
B
Brandon Fergerson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
impl USE_QUALIFIED_NAME_AS_ENDPOINT_NAME
上级
eb19715f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
20 deletion
+73
-20
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
...ava/org/apache/skywalking/apm/agent/core/conf/Config.java
+14
-0
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
+27
-7
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java
.../commons/interceptor/RequestMappingMethodInterceptor.java
+15
-6
apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/RequestMappingMethodInterceptor.java
...in/spring/webflux/v5/RequestMappingMethodInterceptor.java
+15
-6
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java
...it/activation/trace/TraceAnnotationMethodInterceptor.java
+2
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
浏览文件 @
62f21330
...
@@ -163,5 +163,19 @@ public class Config {
...
@@ -163,5 +163,19 @@ public class Config {
*/
*/
public
static
boolean
TRACE_DSL
=
false
;
public
static
boolean
TRACE_DSL
=
false
;
}
}
public
static
class
SpringMVC
{
/**
* If true, the fully qualified method name will be used as the endpoint name instead of the request URL, default is false.
*/
public
static
boolean
USE_QUALIFIED_NAME_AS_ENDPOINT_NAME
=
false
;
}
public
static
class
Toolkit
{
/**
* If true, the fully qualified method name will be used as the endpoint name instead of the operation name, default is false.
*/
public
static
boolean
USE_QUALIFIED_NAME_AS_ENDPOINT_NAME
=
false
;
}
}
}
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
浏览文件 @
62f21330
...
@@ -21,6 +21,7 @@ package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
...
@@ -21,6 +21,7 @@ package org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.skywalking.apm.agent.core.conf.Config
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
...
@@ -56,12 +57,18 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
...
@@ -56,12 +57,18 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
return
;
return
;
}
}
EnhanceRequireObjectCache
pathMappingCache
=
(
EnhanceRequireObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
String
operationName
;
String
requestURL
=
pathMappingCache
.
findPathMapping
(
method
);
if
(
Config
.
Plugin
.
SpringMVC
.
USE_QUALIFIED_NAME_AS_ENDPOINT_NAME
)
{
if
(
requestURL
==
null
)
{
operationName
=
getFullyQualifiedMethodName
(
method
);
requestURL
=
getRequestURL
(
method
);
}
else
{
pathMappingCache
.
addPathMapping
(
method
,
requestURL
);
EnhanceRequireObjectCache
pathMappingCache
=
(
EnhanceRequireObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
requestURL
=
pathMappingCache
.
findPathMapping
(
method
);
String
requestURL
=
pathMappingCache
.
findPathMapping
(
method
);
if
(
requestURL
==
null
)
{
requestURL
=
getRequestURL
(
method
);
pathMappingCache
.
addPathMapping
(
method
,
requestURL
);
requestURL
=
pathMappingCache
.
findPathMapping
(
method
);
}
operationName
=
requestURL
;
}
}
HttpServletRequest
request
=
(
HttpServletRequest
)
ContextManager
.
getRuntimeContext
().
get
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
HttpServletRequest
request
=
(
HttpServletRequest
)
ContextManager
.
getRuntimeContext
().
get
(
REQUEST_KEY_IN_RUNTIME_CONTEXT
);
...
@@ -73,7 +80,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
...
@@ -73,7 +80,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
next
.
setHeadValue
(
request
.
getHeader
(
next
.
getHeadKey
()));
}
}
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
requestURL
,
contextCarrier
);
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
operationName
,
contextCarrier
);
Tags
.
URL
.
set
(
span
,
request
.
getRequestURL
().
toString
());
Tags
.
URL
.
set
(
span
,
request
.
getRequestURL
().
toString
());
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
getMethod
());
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
getMethod
());
span
.
setComponent
(
ComponentsDefine
.
SPRING_MVC_ANNOTATION
);
span
.
setComponent
(
ComponentsDefine
.
SPRING_MVC_ANNOTATION
);
...
@@ -116,4 +123,17 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
...
@@ -116,4 +123,17 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
public
static
String
getFullyQualifiedMethodName
(
Method
method
)
{
StringBuilder
operationName
=
new
StringBuilder
(
method
.
getDeclaringClass
().
getName
()
+
"."
+
method
.
getName
()
+
"("
);
Class
<?>[]
parameterTypes
=
method
.
getParameterTypes
();
for
(
int
i
=
0
;
i
<
parameterTypes
.
length
;
i
++)
{
operationName
.
append
(
parameterTypes
[
i
].
getName
());
if
(
i
<
(
parameterTypes
.
length
-
1
))
{
operationName
.
append
(
","
);
}
}
operationName
.
append
(
")"
);
return
operationName
.
toString
();
}
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/RequestMappingMethodInterceptor.java
浏览文件 @
62f21330
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
*
*
*/
*/
package
org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor
;
package
org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -25,20 +24,30 @@ import java.lang.reflect.Method;
...
@@ -25,20 +24,30 @@ import java.lang.reflect.Method;
/**
/**
* The <code>RequestMappingMethodInterceptor</code> only use the first mapping value.
* The <code>RequestMappingMethodInterceptor</code> only use the first mapping value.
* it will inteceptor with <code>@RequestMapping</code>
* it will inte
r
ceptor with <code>@RequestMapping</code>
*
*
* @author clevertension
* @author clevertension
*/
*/
public
class
RequestMappingMethodInterceptor
extends
AbstractMethodInterceptor
{
public
class
RequestMappingMethodInterceptor
extends
AbstractMethodInterceptor
{
@Override
@Override
public
String
getRequestURL
(
Method
method
)
{
public
String
getRequestURL
(
Method
method
)
{
String
requestURL
=
""
;
String
Builder
requestURL
=
new
StringBuilder
()
;
RequestMapping
methodRequestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
RequestMapping
methodRequestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
if
(
methodRequestMapping
.
method
().
length
>
0
)
{
requestURL
.
append
(
"{"
);
for
(
int
i
=
0
;
i
<
methodRequestMapping
.
method
().
length
;
i
++)
{
requestURL
.
append
(
methodRequestMapping
.
method
()[
i
].
toString
());
if
(
methodRequestMapping
.
method
().
length
>
(
i
+
1
))
{
requestURL
.
append
(
","
);
}
}
requestURL
=
new
StringBuilder
(
"}"
);
}
if
(
methodRequestMapping
.
value
().
length
>
0
)
{
if
(
methodRequestMapping
.
value
().
length
>
0
)
{
requestURL
=
methodRequestMapping
.
value
()[
0
]
;
requestURL
.
append
(
methodRequestMapping
.
value
()[
0
])
;
}
else
if
(
methodRequestMapping
.
path
().
length
>
0
)
{
}
else
if
(
methodRequestMapping
.
path
().
length
>
0
)
{
requestURL
=
methodRequestMapping
.
path
()[
0
]
;
requestURL
.
append
(
methodRequestMapping
.
path
()[
0
])
;
}
}
return
requestURL
;
return
requestURL
.
toString
()
;
}
}
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/RequestMappingMethodInterceptor.java
浏览文件 @
62f21330
...
@@ -15,14 +15,13 @@
...
@@ -15,14 +15,13 @@
* limitations under the License.
* limitations under the License.
*/
*/
package
org.apache.skywalking.apm.plugin.spring.webflux.v5
;
package
org.apache.skywalking.apm.plugin.spring.webflux.v5
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
/**
/**
* The <code>RequestMappingMethodInterceptor</code> only use the first mapping value. it will inteceptor with
* The <code>RequestMappingMethodInterceptor</code> only use the first mapping value. it will inte
r
ceptor with
* <code>@RequestMapping</code>
* <code>@RequestMapping</code>
*
*
* @author clevertension
* @author clevertension
...
@@ -30,13 +29,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -30,13 +29,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
public
class
RequestMappingMethodInterceptor
extends
AbstractMethodInterceptor
{
public
class
RequestMappingMethodInterceptor
extends
AbstractMethodInterceptor
{
@Override
@Override
public
String
getRequestURL
(
Method
method
)
{
public
String
getRequestURL
(
Method
method
)
{
String
requestURL
=
""
;
String
Builder
requestURL
=
new
StringBuilder
()
;
RequestMapping
methodRequestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
RequestMapping
methodRequestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
if
(
methodRequestMapping
.
method
().
length
>
0
)
{
requestURL
.
append
(
"{"
);
for
(
int
i
=
0
;
i
<
methodRequestMapping
.
method
().
length
;
i
++)
{
requestURL
.
append
(
methodRequestMapping
.
method
()[
i
].
toString
());
if
(
methodRequestMapping
.
method
().
length
>
(
i
+
1
))
{
requestURL
.
append
(
","
);
}
}
requestURL
=
new
StringBuilder
(
"}"
);
}
if
(
methodRequestMapping
.
value
().
length
>
0
)
{
if
(
methodRequestMapping
.
value
().
length
>
0
)
{
requestURL
=
methodRequestMapping
.
value
()[
0
]
;
requestURL
.
append
(
methodRequestMapping
.
value
()[
0
])
;
}
else
if
(
methodRequestMapping
.
path
().
length
>
0
)
{
}
else
if
(
methodRequestMapping
.
path
().
length
>
0
)
{
requestURL
=
methodRequestMapping
.
path
()[
0
]
;
requestURL
.
append
(
methodRequestMapping
.
path
()[
0
])
;
}
}
return
requestURL
;
return
requestURL
.
toString
()
;
}
}
}
}
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java
浏览文件 @
62f21330
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
package
org.apache.skywalking.apm.toolkit.activation.trace
;
package
org.apache.skywalking.apm.toolkit.activation.trace
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.conf.Config
;
import
org.apache.skywalking.apm.toolkit.trace.Trace
;
import
org.apache.skywalking.apm.toolkit.trace.Trace
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
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.EnhancedInstance
;
...
@@ -39,7 +40,7 @@ public class TraceAnnotationMethodInterceptor implements InstanceMethodsAroundIn
...
@@ -39,7 +40,7 @@ public class TraceAnnotationMethodInterceptor implements InstanceMethodsAroundIn
MethodInterceptResult
result
)
throws
Throwable
{
MethodInterceptResult
result
)
throws
Throwable
{
Trace
trace
=
method
.
getAnnotation
(
Trace
.
class
);
Trace
trace
=
method
.
getAnnotation
(
Trace
.
class
);
String
operationName
=
trace
.
operationName
();
String
operationName
=
trace
.
operationName
();
if
(
operationName
.
length
()
==
0
)
{
if
(
operationName
.
length
()
==
0
||
Config
.
Plugin
.
Toolkit
.
USE_QUALIFIED_NAME_AS_ENDPOINT_NAME
)
{
operationName
=
generateOperationName
(
method
);
operationName
=
generateOperationName
(
method
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录