Merge branch 'master' into feature/high-performance-agent
* master: add test case and fix logical error Fix windows script start collector failure. fix skywalking container start failure fix lost tags Add mechanism to set default status(on/off) of plugin Add layer tag value: mq. # Conflicts: # apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/Span.java
This commit is contained in:
commit
b3c39aea53
|
|
@ -8,10 +8,13 @@ set COLLECTOR_RUNTIME_OPTIONS="-Xms256M -Xmx512M"
|
|||
set CLASSPATH=%COLLECTOR_BASE_PATH%\config;
|
||||
SET CLASSPATH=%COLLECTOR_BASE_PATH%\libs\*;%CLASSPATH%
|
||||
|
||||
if ""%JAVA_HOME%"" == """" (
|
||||
set _EXECJAVA=java
|
||||
) else (
|
||||
set _EXECJAVA="%JAVA_HOME%"/bin/java
|
||||
if defined JAVA_HOME (
|
||||
set _EXECJAVA="%JAVA_HOME:"=%"\bin\java
|
||||
)
|
||||
|
||||
if not defined JAVA_HOME (
|
||||
echo "JAVA_HOME not set."
|
||||
set _EXECJAVA=java
|
||||
)
|
||||
|
||||
start /MIN "%COLLECOTR_PROCESS_TITLE%" %_EXECJAVA% "%COLLECTOR_RUNTIME_OPTIONS%" -cp "%CLASSPATH%" org.skywalking.apm.collector.worker.CollectorBootStartUp &
|
||||
|
|
|
|||
|
|
@ -101,6 +101,12 @@ public class Config {
|
|||
*/
|
||||
public static List DISABLED_PLUGINS = new LinkedList();
|
||||
|
||||
/**
|
||||
* Name of force enable plugin, The value spilt by <code>,</code>
|
||||
* if you have multiple plugins need to enable.
|
||||
*/
|
||||
public static List FORCE_ENABLE_PLUGINS = new LinkedList();
|
||||
|
||||
public static class MongoDB {
|
||||
/**
|
||||
* If true, trace all the parameters, default is false.
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public final class Tags {
|
|||
private static final String DB_LAYER = "db";
|
||||
private static final String RPC_FRAMEWORK_LAYER = "rpc";
|
||||
private static final String HTTP_LAYER = "http";
|
||||
private static final String MQ_LAYER = "mq";
|
||||
|
||||
public static void asDB(AbstractSpan span) {
|
||||
SPAN_LAYER_TAG.set(span, DB_LAYER);
|
||||
|
|
@ -63,6 +64,10 @@ public final class Tags {
|
|||
public static void asHttp(AbstractSpan span) {
|
||||
SPAN_LAYER_TAG.set(span, HTTP_LAYER);
|
||||
}
|
||||
|
||||
public static void asMQ(AbstractSpan span) {
|
||||
SPAN_LAYER_TAG.set(span, MQ_LAYER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import org.skywalking.apm.agent.core.plugin.exception.IllegalPluginDefineExcepti
|
|||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
public class PluginDefine {
|
||||
public static final String PLUGIN_OFF_PREFIX = "[OFF]";
|
||||
/**
|
||||
* Plugin name.
|
||||
*/
|
||||
|
|
@ -15,9 +16,15 @@ public class PluginDefine {
|
|||
*/
|
||||
private String defineClass;
|
||||
|
||||
private PluginDefine(String name, String defineClass) {
|
||||
/**
|
||||
* The sate of plugin.
|
||||
*/
|
||||
private State state;
|
||||
|
||||
private PluginDefine(String name, String defineClass, State state) {
|
||||
this.name = name;
|
||||
this.defineClass = defineClass;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static PluginDefine build(String define) throws IllegalPluginDefineException {
|
||||
|
|
@ -30,16 +37,34 @@ public class PluginDefine {
|
|||
throw new IllegalPluginDefineException(define);
|
||||
}
|
||||
|
||||
return new PluginDefine(pluginDefine[0], pluginDefine[1]);
|
||||
String pluginName = pluginDefine[0];
|
||||
String defineClass = pluginDefine[1];
|
||||
if (pluginName.toUpperCase().startsWith(PLUGIN_OFF_PREFIX)) {
|
||||
return new PluginDefine(pluginName.substring(PLUGIN_OFF_PREFIX.length()), defineClass, State.OFF);
|
||||
} else {
|
||||
return new PluginDefine(pluginName, defineClass, State.ON);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean enable() {
|
||||
return !Config.Plugin.DISABLED_PLUGINS.contains(name);
|
||||
return !forceDisable() || forceEnable();
|
||||
}
|
||||
|
||||
private boolean forceDisable() {
|
||||
return state != State.ON || Config.Plugin.DISABLED_PLUGINS.contains(name);
|
||||
}
|
||||
|
||||
private boolean forceEnable() {
|
||||
return state == State.OFF && Config.Plugin.FORCE_ENABLE_PLUGINS.contains(name);
|
||||
}
|
||||
|
||||
public String getDefineClass() {
|
||||
return defineClass;
|
||||
}
|
||||
|
||||
private enum State {
|
||||
OFF, ON;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package org.skywalking.apm.agent.core.plugin;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.plugin.exception.IllegalPluginDefineException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PluginDefineTest {
|
||||
|
||||
private static final String TEST_PLUGIN = "test_plugin";
|
||||
private static final String TEST_DEFINE_CLASS = "test_define_class";
|
||||
|
||||
@Test(expected = IllegalPluginDefineException.class)
|
||||
public void testIllegalPluginDefine() throws IllegalPluginDefineException {
|
||||
PluginDefine.build("illegal_plugin_define");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalPluginDefineException.class)
|
||||
public void testEmptyPluginDefine() throws IllegalPluginDefineException {
|
||||
PluginDefine.build("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOffStatePlugin() throws IllegalPluginDefineException {
|
||||
PluginDefine pluginDefine = PluginDefine.build(PluginDefine.PLUGIN_OFF_PREFIX + TEST_PLUGIN + "=" + TEST_DEFINE_CLASS);
|
||||
assertFalse(pluginDefine.enable());
|
||||
assertEquals(TEST_DEFINE_CLASS, pluginDefine.getDefineClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultStatePlugin() throws IllegalPluginDefineException {
|
||||
PluginDefine pluginDefine = PluginDefine.build(TEST_PLUGIN + "=" + TEST_DEFINE_CLASS);
|
||||
assertTrue(pluginDefine.enable());
|
||||
assertEquals(TEST_DEFINE_CLASS, pluginDefine.getDefineClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForceEnablePlugin() throws IllegalPluginDefineException {
|
||||
Config.Plugin.FORCE_ENABLE_PLUGINS.add(TEST_PLUGIN);
|
||||
PluginDefine pluginDefine = PluginDefine.build(PluginDefine.PLUGIN_OFF_PREFIX + TEST_PLUGIN + "=" + TEST_DEFINE_CLASS);
|
||||
assertTrue(pluginDefine.enable());
|
||||
assertEquals(TEST_DEFINE_CLASS, pluginDefine.getDefineClass());
|
||||
Config.Plugin.FORCE_ENABLE_PLUGINS.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -30,6 +30,9 @@ services:
|
|||
es-server:
|
||||
image: elasticsearch:5.3
|
||||
command: "-Enode.name=TestNode -Enetwork.host=0.0.0.0 -Ehttp.cors.enabled=true -Ehttp.cors.allow-origin=* -Ethread_pool.bulk.queue_size=1000 -Ecluster.name=CollectorDBCluster"
|
||||
environment:
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
||||
expose:
|
||||
- "9200"
|
||||
- "9300"
|
||||
|
|
|
|||
Loading…
Reference in New Issue