Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
8b46e5c5
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,发现更多精彩内容 >>
未验证
提交
8b46e5c5
编写于
7月 17, 2020
作者:
D
dagmom
提交者:
GitHub
7月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issue #3713 - Cannot get the TID (#5031)
上级
7b9cbe21
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
136 addition
and
5 deletion
+136
-5
apm-application-toolkit/apm-toolkit-logback-1.x/src/main/java/org/apache/skywalking/apm/toolkit/log/logback/v1/x/logstash/TraceIdJsonProvider.java
...oolkit/log/logback/v1/x/logstash/TraceIdJsonProvider.java
+11
-4
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/log/logback/v1/x/logstash/TraceIdJsonProviderActivation.java
.../logback/v1/x/logstash/TraceIdJsonProviderActivation.java
+68
-0
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/log/logback/v1/x/logstash/TraceIdJsonProviderInterceptor.java
...logback/v1/x/logstash/TraceIdJsonProviderInterceptor.java
+55
-0
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/resources/skywalking-plugin.def
...k-1.x-activation/src/main/resources/skywalking-plugin.def
+2
-1
未找到文件。
apm-application-toolkit/apm-toolkit-logback-1.x/src/main/java/org/apache/skywalking/apm/toolkit/log/logback/v1/x/logstash/TraceIdJsonProvider.java
浏览文件 @
8b46e5c5
...
...
@@ -20,25 +20,32 @@ package org.apache.skywalking.apm.toolkit.log.logback.v1.x.logstash;
import
ch.qos.logback.classic.spi.ILoggingEvent
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
java.io.IOException
;
import
java.util.Map
;
import
net.logstash.logback.composite.AbstractFieldJsonProvider
;
import
net.logstash.logback.composite.FieldNamesAware
;
import
net.logstash.logback.composite.JsonWritingUtils
;
import
net.logstash.logback.fieldnames.LogstashFieldNames
;
import
java.io.IOException
;
import
java.util.Map
;
public
class
TraceIdJsonProvider
extends
AbstractFieldJsonProvider
<
ILoggingEvent
>
implements
FieldNamesAware
<
LogstashFieldNames
>
{
public
static
final
String
TRACING_ID
=
"TID"
;
@Override
public
void
writeTo
(
JsonGenerator
generator
,
ILoggingEvent
event
)
throws
IOException
{
Map
<
String
,
String
>
map
=
event
.
getLoggerContextVO
().
getPropertyMap
(
);
JsonWritingUtils
.
writeStringField
(
generator
,
getFieldName
(),
map
.
get
(
TRACING_ID
)
);
String
tracingId
=
getTracingId
(
event
);
JsonWritingUtils
.
writeStringField
(
generator
,
getFieldName
(),
tracingId
);
}
@Override
public
void
setFieldNames
(
LogstashFieldNames
fieldNames
)
{
setFieldName
(
TRACING_ID
);
}
public
String
getTracingId
(
ILoggingEvent
event
)
{
Map
<
String
,
String
>
map
=
event
.
getLoggerContextVO
().
getPropertyMap
();
return
map
.
get
(
TRACING_ID
);
}
}
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/log/logback/v1/x/logstash/TraceIdJsonProviderActivation.java
0 → 100644
浏览文件 @
8b46e5c5
/*
* 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.toolkit.activation.log.logback.v1.x.logstash
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
public
class
TraceIdJsonProviderActivation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
INTERCEPT_CLASS
=
"org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.logstash.TraceIdJsonProviderInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"org.apache.skywalking.apm.toolkit.log.logback.v1.x.logstash.TraceIdJsonProvider"
;
public
static
final
String
ENHANCE_METHOD
=
"getTracingId"
;
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
null
;
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
NameMatch
.
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/log/logback/v1/x/logstash/TraceIdJsonProviderInterceptor.java
0 → 100644
浏览文件 @
8b46e5c5
/*
* 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.toolkit.activation.log.logback.v1.x.logstash
;
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
java.lang.reflect.Method
;
public
class
TraceIdJsonProviderInterceptor
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
{
if
(
ret
!=
null
&&
!
"N/A"
.
equals
(
ret
))
{
return
ret
;
}
if
(!
ContextManager
.
isActive
()
&&
allArguments
[
0
]
instanceof
EnhancedInstance
)
{
String
tid
=
(
String
)
((
EnhancedInstance
)
allArguments
[
0
]).
getSkyWalkingDynamicField
();
if
(
tid
!=
null
)
{
return
tid
;
}
}
return
ContextManager
.
getGlobalTraceId
();
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/resources/skywalking-plugin.def
浏览文件 @
8b46e5c5
...
...
@@ -18,4 +18,5 @@ toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.Lo
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.mdc.MDCConverterActivation
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.async.AsyncAppenderBaseInstrumentation
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.async.LoggingEventInstrumentation
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.logstash.TcpSocketAppenderActivation
\ No newline at end of file
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.logstash.TcpSocketAppenderActivation
toolkit-logback=org.apache.skywalking.apm.toolkit.activation.log.logback.v1.x.logstash.TraceIdJsonProviderActivation
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录