Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
be736658
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,体验更适合开发者的 AI 搜索 >>
提交
be736658
编写于
12月 25, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a ProtectiveShieldMatcher to prevent match exception.
上级
720f4048
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
71 addition
and
5 deletion
+71
-5
apm-sniffer/apm-agent-core/pom.xml
apm-sniffer/apm-agent-core/pom.xml
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java
...rg/apache/skywalking/apm/agent/core/logging/api/ILog.java
+2
-0
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java
...che/skywalking/apm/agent/core/logging/api/NoopLogger.java
+7
-3
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java
...he/skywalking/apm/agent/core/logging/core/EasyLogger.java
+6
-0
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java
...apache/skywalking/apm/agent/core/plugin/PluginFinder.java
+2
-1
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/ProtectiveShieldMatcher.java
.../apm/agent/core/plugin/match/ProtectiveShieldMatcher.java
+53
-0
未找到文件。
apm-sniffer/apm-agent-core/pom.xml
浏览文件 @
be736658
...
...
@@ -36,7 +36,7 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<jetty.version>
9.4.2.v20170220
</jetty.version>
<grpc.version>
1.8.0
</grpc.version>
<bytebuddy.version>
1.7.
6
</bytebuddy.version>
<bytebuddy.version>
1.7.
9
</bytebuddy.version>
<shade.package>
org.apache.skywalking.apm.dependencies
</shade.package>
<shade.com.lmax.disruptor.source>
com.lmax.disruptor
</shade.com.lmax.disruptor.source>
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/ILog.java
浏览文件 @
be736658
...
...
@@ -33,6 +33,8 @@ public interface ILog {
void
warn
(
String
format
,
Object
...
arguments
);
void
warn
(
Throwable
e
,
String
format
,
Object
...
arguments
);
void
error
(
String
format
,
Throwable
e
);
void
error
(
Throwable
e
,
String
format
,
Object
...
arguments
);
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/api/NoopLogger.java
浏览文件 @
be736658
...
...
@@ -26,9 +26,7 @@ package org.apache.skywalking.apm.agent.core.logging.api;
* Created by xin on 2016/11/10.
*/
public
enum
NoopLogger
implements
ILog
{
INSTANCE
{
};
INSTANCE
;
@Override
public
void
info
(
String
message
)
{
...
...
@@ -89,4 +87,10 @@ public enum NoopLogger implements ILog {
public
void
error
(
Throwable
e
,
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
warn
(
Throwable
e
,
String
format
,
Object
...
arguments
)
{
}
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/EasyLogger.java
浏览文件 @
be736658
...
...
@@ -105,6 +105,12 @@ public class EasyLogger implements ILog {
logger
(
LogLevel
.
WARN
,
replaceParam
(
format
,
arguments
),
null
);
}
@Override
public
void
warn
(
Throwable
e
,
String
format
,
Object
...
arguments
)
{
if
(
isWarnEnable
())
logger
(
LogLevel
.
WARN
,
replaceParam
(
format
,
arguments
),
e
);
}
@Override
public
void
error
(
String
format
,
Throwable
e
)
{
if
(
isErrorEnable
())
...
...
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java
浏览文件 @
be736658
...
...
@@ -30,6 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.bytebuddy.AbstractJunction;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.IndirectMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ProtectiveShieldMatcher
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
isInterface
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
not
;
...
...
@@ -98,6 +99,6 @@ public class PluginFinder {
judge
=
judge
.
or
(((
IndirectMatch
)
match
).
buildJunction
());
}
}
return
judge
;
return
new
ProtectiveShieldMatcher
(
judge
)
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/match/ProtectiveShieldMatcher.java
0 → 100644
浏览文件 @
be736658
/*
* 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.plugin.match
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.logging.api.ILog
;
import
org.apache.skywalking.apm.agent.core.logging.api.LogManager
;
/**
* In same cases, some frameworks and libraries use some binary codes tech too. From the community feedback, some of
* them have compatible issues with byte-buddy core, which trigger "Can't resolve type description" exception.
*
* So I build this protective shield by a nested matcher. When the origin matcher(s) can't resolve the type, the
* SkyWalking agent ignores this types.
*
* Notice: this ignore mechanism may miss some instrumentations, but at most cases, it's same. If missing happens,
* please pay attention to the WARNING logs.
*
* @author wu-sheng
*/
public
class
ProtectiveShieldMatcher
<
T
>
extends
ElementMatcher
.
Junction
.
AbstractBase
<
T
>
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
ProtectiveShieldMatcher
.
class
);
private
final
ElementMatcher
<?
super
T
>
matcher
;
public
ProtectiveShieldMatcher
(
ElementMatcher
<?
super
T
>
matcher
)
{
this
.
matcher
=
matcher
;
}
public
boolean
matches
(
T
target
)
{
try
{
return
this
.
matcher
.
matches
(
target
);
}
catch
(
Throwable
t
)
{
logger
.
warn
(
t
,
"Byte-buddy occurs exception when match type."
);
return
false
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录