-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mechanism to disable any or all plugins #191
Conversation
f2d4f30
to
56daa9a
Compare
Coverage increased (+0.2%) to 71.354% when pulling 56daa9ac1d4039af6f30393e5214da5386de482c on ascrutae:zhangxin/feature/186 into ecf7a2b on wu-sheng:master. |
Coverage increased (+0.07%) to 71.265% when pulling 56daa9ac1d4039af6f30393e5214da5386de482c on ascrutae:zhangxin/feature/186 into ecf7a2b on wu-sheng:master. |
private List<PluginDefine> pluginClassList = new ArrayList<PluginDefine>(); | ||
protected List<String> disabledPlugins = new ArrayList<String>(); | ||
|
||
PluginCfg() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the contructor for initialization should very careful, if this enum is used before config initialization, the disable mechanism will fail.
So I prefer to make the initialization as a boot service, rather than this.
@@ -12,15 +13,29 @@ | |||
public enum PluginCfg { | |||
INSTANCE; | |||
|
|||
private List<String> pluginClassList = new ArrayList<String>(); | |||
private List<PluginDefine> pluginClassList = new ArrayList<PluginDefine>(); | |||
protected List<String> disabledPlugins = new ArrayList<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DisableList is only used in plugin initialization, shouldn't set it as a class field.
@@ -29,6 +44,55 @@ void load(InputStream input) throws IOException { | |||
} | |||
|
|||
public List<String> getPluginClassList() { | |||
return pluginClassList; | |||
List<String> pluginClasses = new ArrayList<String>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need this new list? Just a list copy?
private static class PluginDefine { | ||
|
||
|
||
private static final PluginDefine NOOP_PLUGIN = new PluginDefine() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a Noop. It always set a empty plugin define.
|
||
public static PluginDefine build(String define) { | ||
if (StringUtil.isEmpty(define)) { | ||
return NOOP_PLUGIN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not like the design of retuning noop plugin define. Hard to understand and make no sense.
* if you have multiple plugins need to disable. | ||
* | ||
* Here are the plugin names : | ||
* TOMCAT, DUBBO, JEDIS, MOTAN, HTTPCLIENT, JDBC, MONGODB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All existed config items are in lower case, why choose upper case this time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some plugin names should include version, I think
4e6df40
to
fa39a4c
Compare
Coverage increased (+0.008%) to 71.2% when pulling fa39a4c475c80645a871989140243ad46a46dfa6 on ascrutae:zhangxin/feature/186 into ecf7a2b on wu-sheng:master. |
Coverage increased (+0.1%) to 71.289% when pulling fa39a4c475c80645a871989140243ad46a46dfa6 on ascrutae:zhangxin/feature/186 into ecf7a2b on wu-sheng:master. |
@@ -1 +1 @@ | |||
org.skywalking.apm.plugin.tomcat78x.define.TomcatInstrumentation | |||
tomcat-7.x=org.skywalking.apm.plugin.tomcat78x.define.TomcatInstrumentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the key should be tomcat-7.x/8.x
, if.f /
is legal.
String pluginDefine = null; | ||
while ((pluginDefine = reader.readLine()) != null) { | ||
PluginDefine plugin = PluginDefine.build(pluginDefine); | ||
if (!plugin.disabled(disabledPlugins)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is going to work?
According to premain
public static void premain(String agentArgs, Instrumentation instrumentation) throws PluginException {
SnifferConfigInitializer.initialize();
final PluginFinder pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins());
ServiceManager.INSTANCE.boot();
load(InputStream input)
invokes before ServiceManager.boot
. disabledPlugins(initialize in DisabledPluginInitService
) must be empty every time, how does this pr work?
f88ea4d
to
da32abf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr has evolved to a formal pr. I think you have a lot of works to do.
cc @pengys5
@@ -46,6 +50,19 @@ else if (type.isEnum()) | |||
parentDesc.removeLastDesc(); | |||
} | |||
} | |||
|
|||
private static List convert2List(String value) { | |||
List result = new ArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think LinkedList
is better choice for performance.
* Here are the plugin names : | ||
* tomcat-7.x/8.x, dubbo, jedis-2.x, motan, httpclient-4.x, jdbc, mongodb-3.x. | ||
*/ | ||
public static List DISABLED_PLUGINS = new ArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same performance concern. Prefer LinkedList
.
plugin.setClassTypePool(classTypePool); | ||
plugins.add(plugin); | ||
} catch (Throwable t) { | ||
logger.error(t, "load plugin [{}] failure.", pluginClassName); | ||
logger.error(t, "loade plugin [{}] failure.", pluginDefine.getDefineClass()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loade
, typo.
String pluginDefine = null; | ||
while ((pluginDefine = reader.readLine()) != null) { | ||
PluginDefine plugin = PluginDefine.build(pluginDefine); | ||
if (!plugin.disabled(Config.Plugin.DISABLED_PLUGINS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are using a static field as a parameter, why? You can use is in disabled
method, no parameter is needed.
And I prefer the method name should be boolean enable()
.
|
||
public static PluginDefine build(String define) { | ||
if (StringUtil.isEmpty(define)) { | ||
return IllegalPluginDefine.INSTANCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still don't understand this enum class, also strange name IllegalPluginDefine
. If it is illegal, why don't throw exception?
return defineClass; | ||
} | ||
|
||
static class IllegalPluginDefine extends PluginDefine { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again and again, don't accept this design.
org.skywalking.apm.plugin.jedis.v2.define.JedisClusterInstrumentation | ||
org.skywalking.apm.plugin.jedis.v2.define.JedisInstrumentation | ||
jedis=org.skywalking.apm.plugin.jedis.v2.define.JedisClusterInstrumentation | ||
jedis=org.skywalking.apm.plugin.jedis.v2.define.JedisInstrumentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jedis-2.x
, I think
@@ -1,2 +1,2 @@ | |||
org.skywalking.apm.plugin.motan.define.MotanConsumerInstrumentation | |||
org.skywalking.apm.plugin.motan.define.MotanProviderInstrumentation | |||
motan=org.skywalking.apm.plugin.motan.define.MotanConsumerInstrumentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
motan-0.x
, I think.
@wu-sheng yeah. I think so, I will test it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need some adjustments.
while ((pluginDefine = reader.readLine()) != null) { | ||
try { | ||
PluginDefine plugin = PluginDefine.build(pluginDefine); | ||
if (!plugin.disabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never used disabled
, just want to know enable
or not.
|
||
public static PluginDefine build(String define) throws IllegalPluginDefineException { | ||
if (StringUtil.isEmpty(define)) { | ||
throw new IllegalPluginDefineException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not constructor parameter, why?
|
||
String[] pluginDefine = define.split("="); | ||
if (pluginDefine.length != 2) { | ||
throw new IllegalPluginDefineException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not constructor parameter, why?
32dfb84
to
152715a
Compare
Coverage decreased (-0.09%) to 71.104% when pulling 32dfb848c3bd367e691d2a661aa31c5bda0e5b32 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Coverage decreased (-0.1%) to 71.093% when pulling 152715a7ae008b0bb680b3af5df46734d8b6cf97 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Coverage decreased (-0.01%) to 71.182% when pulling 152715a7ae008b0bb680b3af5df46734d8b6cf97 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need some changes.
|
||
String[] segments = value.split(","); | ||
for (String segment : segments) { | ||
result.add(segment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You miss segment.trim()
and avoid empty string.
|
||
/** | ||
* {@link IllegalPluginDefineException} present that the value of plugin define can | ||
* not be formatted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't understand the comments.....
e12ee04
to
3f902ca
Compare
org.skywalking.apm.toolkit.activation.opentracing.span.SkyWalkingSpanActivation | ||
org.skywalking.apm.toolkit.activation.opentracing.tracer.SkyWalkingTracerActivation | ||
opentracing-0.20.x=org.skywalking.apm.toolkit.activation.opentracing.span.SkyWalkingSpanActivation | ||
opentracing-0.20.x=org.skywalking.apm.toolkit.activation.opentracing.tracer.SkyWalkingTracerActivation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opentracing
activation is based on our application toolkit, so the name should not include version, especially ot version. Keep the name just opentracing
tracecontext-3.x=org.skywalking.apm.toolkit.activation.trace.TraceContextActivation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does 3.x
comes from? Our project version? Same as opentracing-toolkit-activation, just tracecontext
is enough.
8ba8e5a
to
fec9d36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Coverage decreased (-0.01%) to 71.182% when pulling f5565569c148d0a4d609f6158512128d5115e77f on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Coverage decreased (-0.1%) to 71.072% when pulling b04888ce9965c14f8302e286b91826fd33d06e44 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Coverage decreased (-0.1%) to 71.072% when pulling b04888ce9965c14f8302e286b91826fd33d06e44 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Coverage decreased (-0.1%) to 71.072% when pulling 3f902ca5c4e85ce7bcc25752722ea9a00755ec09 on ascrutae:zhangxin/feature/186 into e3a42f7 on wu-sheng:master. |
Relate: #186