You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/07/20 12:39:41 UTC
[skywalking] 01/01: Separate config initialization in the plugin
out of core level Config.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch configInit
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit ca7d57adedb3c5f8dc0cbf0a5fcbc0bc67b6c3ee
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Jul 20 20:39:19 2020 +0800
Separate config initialization in the plugin out of core level Config.
---
.../core/boot/ConfigInitializationService.java | 32 ++++
.../agent/core/boot/PluginConfigInitializer.java | 36 ++++
.../skywalking/apm/agent/core/conf/Config.java | 187 +--------------------
.../agent/core/conf/SnifferConfigInitializer.java | 59 ++++---
.../apm/agent/core/conf/PluginConfig.java | 34 ++++
.../core/conf/PluginConfigInitializerTest.java | 36 ++++
.../core/conf/SnifferConfigInitializerTest.java | 12 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../skywalking/apm/agent/SkyWalkingAgent.java | 4 +-
.../elasticsearch/v5/ElasticsearchConfig.java | 39 +++++
.../v5/TransportActionNodeProxyInterceptor.java | 2 +-
.../v5/TransportProxyClientInterceptor.java | 2 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../elasticsearch/v6/ElasticsearchConfig.java | 39 +++++
...terActionFutureActionGetMethodsInterceptor.java | 4 +-
...ClusterClientPutSettingsMethodsInterceptor.java | 2 +-
.../IndicesClientCreateMethodsInterceptor.java | 2 +-
.../RestHighLevelClientGetMethodsInterceptor.java | 2 +-
...RestHighLevelClientIndexMethodsInterceptor.java | 2 +-
...estHighLevelClientSearchMethodsInterceptor.java | 2 +-
...estHighLevelClientUpdateMethodsInterceptor.java | 2 +-
...rtActionNodeProxyExecuteMethodsInterceptor.java | 5 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
...ctionFutureActionGetMethodsInterceptorTest.java | 2 +-
...terClientPutSettingsMethodsInterceptorTest.java | 2 +-
.../IndicesClientCreateMethodsInterceptorTest.java | 2 +-
...stHighLevelClientGetMethodsInterceptorTest.java | 2 +-
...HighLevelClientIndexMethodsInterceptorTest.java | 2 +-
...ighLevelClientSearchMethodsInterceptorTest.java | 2 +-
...ighLevelClientUpdateMethodsInterceptorTest.java | 2 +-
...tionNodeProxyExecuteMethodsInterceptorTest.java | 22 ++-
.../apm/plugin/influxdb/InfluxDBConfig.java | 37 ++++
.../interceptor/InfluxDBMethodInterceptor.java | 13 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../skywalking/apm/plugin/jdbc/JDBCConfig.java | 77 +++++++++
.../PSSetterDefinitionOfJDBCInstrumentation.java | 6 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../plugin/light4j/HandleRequestInterceptor.java | 27 +--
.../apm/plugin/light4j/Light4JConfig.java | 38 +++++
...apm.agent.core.boot.ConfigInitializationService | 19 +++
...PreparedStatementExecuteMethodsInterceptor.java | 17 +-
...aredStatementExecuteMethodsInterceptorTest.java | 27 +--
.../v2/MongoDBCollectionMethodInterceptorTest.java | 6 -
.../apm/plugin/mongodb/v3/MongoConfig.java | 46 +++++
.../mongodb/v3/support/MongoOperationHelper.java | 9 +-
.../plugin/mongodb/v3/support/MongoSpanHelper.java | 7 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../v3/interceptor/v30/MongoDBInterceptorTest.java | 7 +-
.../MongoDBOperationExecutorInterceptorTest.java | 7 +-
...PreparedStatementExecuteMethodsInterceptor.java | 18 +-
...PreparedStatementExecuteMethodsInterceptor.java | 18 +-
.../apm/plugin/solrj/SolrClientInterceptor.java | 35 ++--
.../skywalking/apm/plugin/solrj/SolrJConfig.java | 43 +++++
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../plugin/solrj/SolrClientInterceptorTest.java | 29 ++--
.../plugin/spring/mvc/commons/SpringMVCConfig.java | 53 ++++++
.../interceptor/AbstractMethodInterceptor.java | 23 +--
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../apm/plugin/tomcat78x/TomcatConfig.java | 46 +++++
.../plugin/tomcat78x/TomcatInvokeInterceptor.java | 23 +--
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../toolkit/activation/ToolkitConfigService.java | 38 +++++
.../trace/TraceAnnotationMethodInterceptor.java | 23 ++-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../plugin/jdk/threading/JDKThreadingConfig.java | 40 +++++
.../apm/plugin/jdk/threading/ThreadingConfig.java | 6 +-
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../apm/plugin/customize/conf/ConfigService.java | 45 +++++
.../customize/conf/CustomizeConfiguration.java | 65 ++++---
...apm.agent.core.boot.ConfigInitializationService | 19 +++
.../GetTransactionMethodInterceptor.java | 23 +--
.../plugin/spring/transaction/SpringTXConfig.java | 38 +++++
...apm.agent.core.boot.ConfigInitializationService | 19 +++
73 files changed, 1274 insertions(+), 421 deletions(-)
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/ConfigInitializationService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/ConfigInitializationService.java
new file mode 100644
index 0000000..243c601
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/ConfigInitializationService.java
@@ -0,0 +1,32 @@
+/*
+ * 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.boot;
+
+/**
+ * ConfigInitializationService provides the config class which should host all parameters originally from agent setup.
+ * {@link org.apache.skywalking.apm.agent.core.conf.Config} provides the core level config, all plugins could implement
+ * this interface to have the same capability about initializing config from agent.config, system properties and system
+ * environment variables.
+ */
+public interface ConfigInitializationService {
+ /**
+ * @return Config to host parameters, all static fields set based on the config variable name.
+ */
+ Class config();
+}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/PluginConfigInitializer.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/PluginConfigInitializer.java
new file mode 100644
index 0000000..32b4f43
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/boot/PluginConfigInitializer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.boot;
+
+import java.util.ServiceLoader;
+import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer;
+import org.apache.skywalking.apm.agent.core.plugin.loader.AgentClassLoader;
+
+/**
+ * PluginConfigInitializer loads Config(s) in all existing plugins, and initialize them through current agent settings.
+ */
+public class PluginConfigInitializer {
+ public void initConfigurationsOfAllPlugins() {
+ final ServiceLoader<ConfigInitializationService> configServiceLoader = ServiceLoader.load(
+ ConfigInitializationService.class, AgentClassLoader.getDefault());
+ configServiceLoader.forEach(configInitializationService -> {
+ SnifferConfigInitializer.initializeConfig(configInitializationService.config());
+ });
+ }
+}
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
index 2e13d01..1d89ec5 100755
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
@@ -27,7 +27,6 @@ import org.apache.skywalking.apm.agent.core.logging.core.WriterFactory;
import org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ClassCacheMode;
import org.apache.skywalking.apm.util.Length;
-
/**
* This is the core config in sniffer agent.
*/
@@ -76,15 +75,15 @@ public class Config {
public static boolean IS_OPEN_DEBUGGING_CLASS = false;
/**
- * If true, SkyWalking agent will cache all instrumented classes to memory or disk files (decided by class cache mode),
- * allow other javaagent to enhance those classes that enhanced by SkyWalking agent.
+ * If true, SkyWalking agent will cache all instrumented classes to memory or disk files (decided by class cache
+ * mode), allow other javaagent to enhance those classes that enhanced by SkyWalking agent.
*/
public static boolean IS_CACHE_ENHANCED_CLASS = false;
/**
- * The instrumented classes cache mode: MEMORY or FILE
- * MEMORY: cache class bytes to memory, if instrumented classes is too many or too large, it may take up more memory
- * FILE: cache class bytes in `/class-cache` folder, automatically clean up cached class files when the application exits
+ * The instrumented classes cache mode: MEMORY or FILE MEMORY: cache class bytes to memory, if instrumented
+ * classes is too many or too large, it may take up more memory FILE: cache class bytes in `/class-cache`
+ * folder, automatically clean up cached class files when the application exits
*/
public static ClassCacheMode CLASS_CACHE_MODE = ClassCacheMode.MEMORY;
@@ -94,10 +93,8 @@ public class Config {
@Length(50)
public volatile static String INSTANCE_NAME = "";
- /*
- * service instance properties
- * e.g.
- * agent.instance_properties[org]=apache
+ /**
+ * service instance properties e.g. agent.instance_properties[org]=apache
*/
public static Map<String, String> INSTANCE_PROPERTIES = new HashMap<>();
@@ -264,180 +261,10 @@ public class Config {
}
public static class Plugin {
-
/**
* Control the length of the peer field.
*/
public static int PEER_MAX_LENGTH = 200;
-
- public static class MongoDB {
- /**
- * If true, trace all the parameters in MongoDB access, default is false. Only trace the operation, not
- * include parameters.
- */
- public static boolean TRACE_PARAM = false;
-
- /**
- * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
- * the first {@code FILTER_LENGTH_LIMIT} characters.
- * <p>
- * Set a negative number to save the complete parameter string to the tag.
- */
- public static int FILTER_LENGTH_LIMIT = 256;
- }
-
- public static class Elasticsearch {
- /**
- * If true, trace all the DSL(Domain Specific Language) in ElasticSearch access, default is false.
- */
- public static boolean TRACE_DSL = false;
-
- public static int ELASTICSEARCH_DSL_LENGTH_THRESHOLD = 1024;
- }
-
- public static class Customize {
- /**
- * Custom enhancement class configuration file path, recommended to use an absolute path.
- */
- public static String ENHANCE_FILE = "";
-
- /**
- * Some information after custom enhancements, this configuration is used by the custom enhancement plugin.
- * And using Map CONTEXT for avoiding classloader isolation issue.
- */
- public static Map<String, Object> CONTEXT = new HashMap<>();
- }
-
- public static class Tomcat {
- /**
- * This config item controls that whether the Tomcat plugin should collect the parameters of the request.
- */
- public static boolean COLLECT_HTTP_PARAMS = 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;
-
- /**
- * This config item controls that whether the SpringMVC plugin should collect the parameters of the
- * request.
- */
- public static boolean COLLECT_HTTP_PARAMS = false;
- }
-
- public static class Toolkit {
- /**
- * If true, the fully qualified method name will be used as the operation name instead of the given
- * operation name, default is false.
- */
- public static boolean USE_QUALIFIED_NAME_AS_OPERATION_NAME = false;
- }
-
- public static class MySQL {
- /**
- * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
- * collected.
- */
- public static boolean TRACE_SQL_PARAMETERS = false;
- /**
- * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
- * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
- * <p>
- * Set a negative number to save the complete parameter string to the tag.
- */
- public static int SQL_PARAMETERS_MAX_LENGTH = 512;
- }
-
- public static class POSTGRESQL {
- /**
- * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
- * collected.
- */
- public static boolean TRACE_SQL_PARAMETERS = false;
-
- /**
- * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
- * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
- * <p>
- * Set a negative number to save the complete parameter string to the tag.
- */
- public static int SQL_PARAMETERS_MAX_LENGTH = 512;
- }
-
- public static class MARIADB {
- /**
- * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
- * collected.
- */
- public static boolean TRACE_SQL_PARAMETERS = false;
-
- /**
- * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
- * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
- * <p>
- * Set a negative number to save the complete parameter string to the tag.
- */
- public static int SQL_PARAMETERS_MAX_LENGTH = 512;
- }
-
- public static class SolrJ {
- /**
- * If true, trace all the query parameters(include deleteByIds and deleteByQuery) in Solr query request,
- * default is false.
- */
- public static boolean TRACE_STATEMENT = false;
-
- /**
- * If true, trace all the operation parameters in Solr request, default is false.
- */
- public static boolean TRACE_OPS_PARAMS = false;
- }
-
- public static class Light4J {
- /**
- * If true, trace all middleware/business handlers that are part of the Light4J handler chain for a request,
- * generating a local span for each.
- */
- public static boolean TRACE_HANDLER_CHAIN = false;
- }
-
- public static class SpringTransaction {
-
- /**
- * If true, the transaction definition name will be simplified
- */
- public static boolean SIMPLIFY_TRANSACTION_DEFINITION_NAME = false;
- }
-
- public static class JdkThreading {
-
- /**
- * Threading classes ({@link java.lang.Runnable} and {@link java.util.concurrent.Callable} and their
- * subclasses, including anonymous inner classes) whose name matches any one of the {@code
- * THREADING_CLASS_PREFIXES} (splitted by ,) will be instrumented
- */
- public static String THREADING_CLASS_PREFIXES = "";
- }
-
- public static class Http {
- /**
- * When either {@link Tomcat#COLLECT_HTTP_PARAMS} or {@link SpringMVC#COLLECT_HTTP_PARAMS} is enabled, how
- * many characters to keep and send to the OAP backend, use negative values to keep and send the complete
- * parameters, NB. this config item is added for the sake of performance
- */
- public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024;
- }
-
- public static class InfluxDB {
- /**
- * If set to true, the parameters of the InfluxQL would be collected.
- */
- public static boolean TRACE_INFLUXQL = true;
- }
}
public static class Correlation {
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
index a4d8c11..69042c8 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
@@ -44,6 +44,7 @@ public class SnifferConfigInitializer {
private static final String SPECIFIED_CONFIG_PATH = "skywalking_config";
private static final String DEFAULT_CONFIG_FILE_NAME = "/config/agent.config";
private static final String ENV_KEY_PREFIX = "skywalking.";
+ private static Properties AGENT_SETTINGS;
private static boolean IS_INIT_COMPLETED = false;
/**
@@ -57,15 +58,15 @@ public class SnifferConfigInitializer {
* <p>
* At the end, `agent.service_name` and `collector.servers` must not be blank.
*/
- public static void initialize(String agentOptions) {
+ public static void initializeCoreConfig(String agentOptions) {
+ AGENT_SETTINGS = new Properties();
try (final InputStreamReader configFileStream = loadConfig()) {
- Properties properties = new Properties();
- properties.load(configFileStream);
- for (String key : properties.stringPropertyNames()) {
- String value = (String) properties.get(key);
- properties.put(key, PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(value, properties));
+ AGENT_SETTINGS.load(configFileStream);
+ for (String key : AGENT_SETTINGS.stringPropertyNames()) {
+ String value = (String) AGENT_SETTINGS.get(key);
+ AGENT_SETTINGS.put(key, PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(value, AGENT_SETTINGS));
}
- ConfigInitializer.initialize(properties, Config.class);
+
} catch (Exception e) {
logger.error(e, "Failed to read the config file, skywalking is going to run in default config.");
}
@@ -88,6 +89,8 @@ public class SnifferConfigInitializer {
}
}
+ initializeConfig(Config.class);
+
if (StringUtil.isEmpty(Config.Agent.SERVICE_NAME)) {
throw new ExceptionInInitializerError("`agent.service_name` is missing.");
}
@@ -95,23 +98,43 @@ public class SnifferConfigInitializer {
throw new ExceptionInInitializerError("`collector.backend_service` is missing.");
}
if (Config.Plugin.PEER_MAX_LENGTH <= 3) {
- logger.warn("PEER_MAX_LENGTH configuration:{} error, the default value of 200 will be used.", Config.Plugin.PEER_MAX_LENGTH);
+ logger.warn(
+ "PEER_MAX_LENGTH configuration:{} error, the default value of 200 will be used.",
+ Config.Plugin.PEER_MAX_LENGTH
+ );
Config.Plugin.PEER_MAX_LENGTH = 200;
}
IS_INIT_COMPLETED = true;
}
+ /**
+ * Initialize field values of any given config class.
+ *
+ * @param configClass to host the settings for code access.
+ */
+ public static void initializeConfig(Class configClass) {
+ if (AGENT_SETTINGS == null) {
+ logger.error("Plugin configs have to be initialized after core config initialization.");
+ return;
+ }
+ try {
+ ConfigInitializer.initialize(AGENT_SETTINGS, configClass);
+ } catch (IllegalAccessException e) {
+ logger.error(e,
+ "Failed to set the agent settings {}"
+ + " to Config={} ",
+ AGENT_SETTINGS, configClass
+ );
+ }
+ }
+
private static void overrideConfigByAgentOptions(String agentOptions) throws IllegalAccessException {
- Properties properties = new Properties();
for (List<String> terms : parseAgentOptions(agentOptions)) {
if (terms.size() != 2) {
throw new IllegalArgumentException("[" + terms + "] is not a key-value pair.");
}
- properties.put(terms.get(0), terms.get(1));
- }
- if (!properties.isEmpty()) {
- ConfigInitializer.initialize(properties, Config.class);
+ AGENT_SETTINGS.put(terms.get(0), terms.get(1));
}
}
@@ -153,19 +176,14 @@ public class SnifferConfigInitializer {
* such as: Property key of `agent.service_name` should be `skywalking.agent.service_name`
*/
private static void overrideConfigBySystemProp() throws IllegalAccessException {
- Properties properties = new Properties();
Properties systemProperties = System.getProperties();
for (final Map.Entry<Object, Object> prop : systemProperties.entrySet()) {
String key = prop.getKey().toString();
if (key.startsWith(ENV_KEY_PREFIX)) {
String realKey = key.substring(ENV_KEY_PREFIX.length());
- properties.put(realKey, prop.getValue());
+ AGENT_SETTINGS.put(realKey, prop.getValue());
}
}
-
- if (!properties.isEmpty()) {
- ConfigInitializer.initialize(properties, Config.class);
- }
}
/**
@@ -175,7 +193,8 @@ public class SnifferConfigInitializer {
*/
private static InputStreamReader loadConfig() throws AgentPackageNotFoundException, ConfigNotFoundException {
String specifiedConfigPath = System.getProperty(SPECIFIED_CONFIG_PATH);
- File configFile = StringUtil.isEmpty(specifiedConfigPath) ? new File(AgentPackagePath.getPath(), DEFAULT_CONFIG_FILE_NAME) : new File(specifiedConfigPath);
+ File configFile = StringUtil.isEmpty(specifiedConfigPath) ? new File(
+ AgentPackagePath.getPath(), DEFAULT_CONFIG_FILE_NAME) : new File(specifiedConfigPath);
if (configFile.exists() && configFile.isFile()) {
try {
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfig.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfig.java
new file mode 100644
index 0000000..1ec70fd
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfig.java
@@ -0,0 +1,34 @@
+/*
+ * 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.conf;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class PluginConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return PluginConfig.class;
+ }
+
+ public static class Plugin {
+ public static class Dummy {
+ public static String ATTR = "1";
+ }
+ }
+}
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfigInitializerTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfigInitializerTest.java
new file mode 100644
index 0000000..3d9c970
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/PluginConfigInitializerTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.conf;
+
+import org.apache.skywalking.apm.agent.core.boot.PluginConfigInitializer;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PluginConfigInitializerTest {
+ @Test
+ public void test() {
+ System.setProperty("skywalking.agent.service_name", "testApp");
+ System.setProperty("skywalking.collector.backend_service", "127.0.0.1:8090");
+ System.setProperty("skywalking.plugin.dummy.attr", "abc");
+ SnifferConfigInitializer.initializeCoreConfig("");
+ new PluginConfigInitializer().initConfigurationsOfAllPlugins();
+
+ Assert.assertEquals("abc", PluginConfig.Plugin.Dummy.ATTR);
+ }
+}
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java
index 1575261..5306118 100644
--- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java
@@ -48,7 +48,7 @@ public class SnifferConfigInitializerTest {
System.setProperty("skywalking.agent.service_name", "testApp");
System.setProperty("skywalking.collector.backend_service", "127.0.0.1:8090");
System.setProperty("skywalking.logging.level", "info");
- SnifferConfigInitializer.initialize(null);
+ SnifferConfigInitializer.initializeCoreConfig(null);
assertThat(Config.Agent.SERVICE_NAME, is("testApp"));
assertThat(Config.Collector.BACKEND_SERVICE, is("127.0.0.1:8090"));
assertThat(Config.Logging.LEVEL, is(LogLevel.INFO));
@@ -57,7 +57,7 @@ public class SnifferConfigInitializerTest {
@Test
public void testLoadConfigFromAgentOptions() throws AgentPackageNotFoundException, ConfigNotFoundException {
String agentOptions = "agent.service_name=testApp,collector.backend_service=127.0.0.1:8090,logging.level=info";
- SnifferConfigInitializer.initialize(agentOptions);
+ SnifferConfigInitializer.initializeCoreConfig(agentOptions);
assertThat(Config.Agent.SERVICE_NAME, is("testApp"));
assertThat(Config.Collector.BACKEND_SERVICE, is("127.0.0.1:8090"));
assertThat(Config.Logging.LEVEL, is(LogLevel.INFO));
@@ -70,7 +70,7 @@ public class SnifferConfigInitializerTest {
System.setProperty("skywalking.agent.instance_properties[key2]", "value2");
System.setProperty("skywalking.collector.backend_service", "127.0.0.1:8090");
String agentOptions = "agent.service_name=testAppFromAgentOptions,logging.level=debug";
- SnifferConfigInitializer.initialize(agentOptions);
+ SnifferConfigInitializer.initializeCoreConfig(agentOptions);
assertThat(Config.Agent.SERVICE_NAME, is("testAppFromAgentOptions"));
assertThat(Config.Collector.BACKEND_SERVICE, is("127.0.0.1:8090"));
assertThat(Config.Logging.LEVEL, is(LogLevel.DEBUG));
@@ -98,7 +98,7 @@ public class SnifferConfigInitializerTest {
System.setProperty("skywalking.agent.service_name", "testApp");
System.setProperty("skywalking.collector.backend_service", "127.0.0.1:8090");
String agentOptions = "agent.ignore_suffix='.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg'";
- SnifferConfigInitializer.initialize(agentOptions);
+ SnifferConfigInitializer.initializeCoreConfig(agentOptions);
assertThat(Config.Agent.IGNORE_SUFFIX, is(".jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg"));
}
@@ -107,13 +107,13 @@ public class SnifferConfigInitializerTest {
System.setProperty("skywalking.collector.backend_service", "127.0.0.1:8090");
String agentOptions = "agent.service_name=test=abc";
try {
- SnifferConfigInitializer.initialize(agentOptions);
+ SnifferConfigInitializer.initializeCoreConfig(agentOptions);
fail("test=abc without quotes is not a valid value");
} catch (ExceptionInInitializerError e) {
// ignore
}
agentOptions = "agent.service_name='test=abc'";
- SnifferConfigInitializer.initialize(agentOptions);
+ SnifferConfigInitializer.initializeCoreConfig(agentOptions);
assertThat(Config.Agent.SERVICE_NAME, is("test=abc"));
}
diff --git a/apm-sniffer/apm-agent-core/src/test/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-agent-core/src/test/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..2897fc9
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/test/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.agent.core.conf.PluginConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
index 3f0c259..ae2dd86 100644
--- a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
+++ b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
@@ -30,6 +30,7 @@ import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.utility.JavaModule;
import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
+import org.apache.skywalking.apm.agent.core.boot.PluginConfigInitializer;
import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer;
@@ -61,10 +62,11 @@ public class SkyWalkingAgent {
public static void premain(String agentArgs, Instrumentation instrumentation) throws PluginException {
final PluginFinder pluginFinder;
try {
- SnifferConfigInitializer.initialize(agentArgs);
+ SnifferConfigInitializer.initializeCoreConfig(agentArgs);
pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins());
+ new PluginConfigInitializer().initConfigurationsOfAllPlugins();
} catch (AgentPackageNotFoundException ape) {
logger.error(ape, "Locate agent.jar failure. Shutting down.");
return;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/ElasticsearchConfig.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/ElasticsearchConfig.java
new file mode 100644
index 0000000..e2277c8
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/ElasticsearchConfig.java
@@ -0,0 +1,39 @@
+/*
+ * 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.plugin.elasticsearch.v5;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class ElasticsearchConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return ElasticsearchConfig.class;
+ }
+
+ public static class Plugin {
+ public static class Elasticsearch {
+ /**
+ * If true, trace all the DSL(Domain Specific Language) in ElasticSearch access, default is false.
+ */
+ public static boolean TRACE_DSL = false;
+
+ public static int ELASTICSEARCH_DSL_LENGTH_THRESHOLD = 1024;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportActionNodeProxyInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportActionNodeProxyInterceptor.java
index 59b3b3b..6b15b20 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportActionNodeProxyInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportActionNodeProxyInterceptor.java
@@ -30,7 +30,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.elasticsearch.cluster.node.DiscoveryNode;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v5.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v5.Constants.DB_TYPE;
import static org.apache.skywalking.apm.plugin.elasticsearch.v5.Constants.ELASTICSEARCH_DB_OP_PREFIX;
import static org.apache.skywalking.apm.plugin.elasticsearch.v5.Constants.ES_INDEX;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportProxyClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportProxyClientInterceptor.java
index c707af8..02d12ea 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportProxyClientInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v5/TransportProxyClientInterceptor.java
@@ -33,7 +33,7 @@ import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v5.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
public class TransportProxyClientInterceptor implements InstanceConstructorInterceptor {
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..6589117
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-5.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.elasticsearch.v5.ElasticsearchConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/ElasticsearchConfig.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/ElasticsearchConfig.java
new file mode 100644
index 0000000..e10398e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/ElasticsearchConfig.java
@@ -0,0 +1,39 @@
+/*
+ * 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.plugin.elasticsearch.v6;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class ElasticsearchConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return ElasticsearchConfig.class;
+ }
+
+ public static class Plugin {
+ public static class Elasticsearch {
+ /**
+ * If true, trace all the DSL(Domain Specific Language) in ElasticSearch access, default is false.
+ */
+ public static boolean TRACE_DSL = false;
+
+ public static int ELASTICSEARCH_DSL_LENGTH_THRESHOLD = 1024;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
index 7a15809..e16f4fa 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
@@ -36,8 +36,8 @@ import org.elasticsearch.action.update.UpdateResponse;
import java.lang.reflect.Method;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.ELASTICSEARCH_DSL_LENGTH_THRESHOLD;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.ELASTICSEARCH_DSL_LENGTH_THRESHOLD;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
public class AdapterActionFutureActionGetMethodsInterceptor implements InstanceMethodsAroundInterceptor {
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptor.java
index 63aa133..e306d3a 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptor.java
index c48820f..dd8c6a2 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptor.java
index a9df313..aeed206 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptor.java
index b9fa8ef..a56e92c 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptor.java
index 6d33ea5..9c495ea 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptor.java
index c025999..dcca4c4 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptor.java
index af9d1e6..deb9e9d 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptor.java
@@ -18,6 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@@ -38,9 +39,7 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.cluster.node.DiscoveryNode;
-import java.lang.reflect.Method;
-
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
public class TransportActionNodeProxyExecuteMethodsInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor {
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..60dea84
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptorTest.java
index 3754c41..fd7225e 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptorTest.java
@@ -44,7 +44,7 @@ import org.powermock.modules.junit4.PowerMockRunnerDelegate;
import java.util.List;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.TRANSPORT_CLIENT;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptorTest.java
index fac1c27..5db9e48 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/ClusterClientPutSettingsMethodsInterceptorTest.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptorTest.java
index 17e9e6c..8fbf92a 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/IndicesClientCreateMethodsInterceptorTest.java
@@ -42,7 +42,7 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptorTest.java
index 10d2ff8..82ea133 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientGetMethodsInterceptorTest.java
@@ -41,7 +41,7 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptorTest.java
index 3580fdb..fa40f46 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientIndexMethodsInterceptorTest.java
@@ -41,7 +41,7 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptorTest.java
index 2969740..a63cfd9 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientSearchMethodsInterceptorTest.java
@@ -42,7 +42,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptorTest.java
index e642420..e77aae7 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientUpdateMethodsInterceptorTest.java
@@ -41,7 +41,7 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptorTest.java
index 68c1f28..940db27 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/TransportActionNodeProxyExecuteMethodsInterceptorTest.java
@@ -18,6 +18,8 @@
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
+import java.net.InetSocketAddress;
+import java.util.List;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.ExitSpan;
import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
@@ -48,13 +50,10 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import java.net.InetSocketAddress;
-import java.util.List;
-
-import static org.apache.skywalking.apm.agent.core.conf.Config.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.TRANSPORT_CLIENT;
-import static org.junit.Assert.assertThat;
+import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
@RunWith(PowerMockRunner.class)
@@ -116,7 +115,7 @@ public class TransportActionNodeProxyExecuteMethodsInterceptorTest {
when(deleteRequest.index()).thenReturn("endpoint");
when(deleteRequest.type()).thenReturn("deleteType");
- when(deleteIndexRequest.indices()).thenReturn(new String[]{"endpoint"});
+ when(deleteIndexRequest.indices()).thenReturn(new String[] {"endpoint"});
interceptor = new TransportActionNodeProxyExecuteMethodsInterceptor();
}
@@ -153,7 +152,11 @@ public class TransportActionNodeProxyExecuteMethodsInterceptorTest {
};
objInst1.setSkyWalkingDynamicField(123);
- Object[] allArguments = new Object[]{null, null, objInst1};
+ Object[] allArguments = new Object[] {
+ null,
+ null,
+ objInst1
+ };
interceptor.onConstruct(objInst2, allArguments);
assertThat(objInst1.getSkyWalkingDynamicField(), is(objInst2.getSkyWalkingDynamicField()));
@@ -196,7 +199,10 @@ public class TransportActionNodeProxyExecuteMethodsInterceptorTest {
private AbstractTracingSpan getSpan(ActionRequest actionRequest) throws Throwable {
TRACE_DSL = true;
- Object[] allArguments = new Object[]{discoveryNode, actionRequest};
+ Object[] allArguments = new Object[] {
+ discoveryNode,
+ actionRequest
+ };
interceptor.beforeMethod(enhancedInstance, null, allArguments, null, null);
interceptor.afterMethod(enhancedInstance, null, allArguments, null, null);
diff --git a/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/InfluxDBConfig.java b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/InfluxDBConfig.java
new file mode 100644
index 0000000..a6ed588
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/InfluxDBConfig.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.influxdb;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class InfluxDBConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return InfluxDBConfig.class;
+ }
+
+ public static class Plugin {
+ public static class InfluxDB {
+ /**
+ * If set to true, the parameters of the InfluxQL would be collected.
+ */
+ public static boolean TRACE_INFLUXQL = true;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/interceptor/InfluxDBMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/interceptor/InfluxDBMethodInterceptor.java
index 252cc64..df89c17 100644
--- a/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/interceptor/InfluxDBMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/influxdb/interceptor/InfluxDBMethodInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.influxdb.interceptor;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@@ -27,20 +27,19 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.apache.skywalking.apm.plugin.influxdb.InfluxDBConfig;
import org.apache.skywalking.apm.plugin.influxdb.define.Constants;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.Query;
-import java.lang.reflect.Method;
-
import static org.apache.skywalking.apm.plugin.influxdb.define.Constants.DB_TYPE;
public class InfluxDBMethodInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
String methodName = method.getName();
String peer = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan("InfluxDB/" + methodName, peer);
@@ -48,7 +47,7 @@ public class InfluxDBMethodInterceptor implements InstanceMethodsAroundIntercept
SpanLayer.asDB(span);
Tags.DB_TYPE.set(span, DB_TYPE);
- if (allArguments.length <= 0 || !Config.Plugin.InfluxDB.TRACE_INFLUXQL) {
+ if (allArguments.length <= 0 || !InfluxDBConfig.Plugin.InfluxDB.TRACE_INFLUXQL) {
return;
}
@@ -85,14 +84,14 @@ public class InfluxDBMethodInterceptor implements InstanceMethodsAroundIntercept
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
ContextManager.stopSpan();
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..68b7621
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/influxdb-2.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.influxdb.InfluxDBConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/JDBCConfig.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/JDBCConfig.java
new file mode 100644
index 0000000..538dd3c
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/JDBCConfig.java
@@ -0,0 +1,77 @@
+/*
+ * 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.plugin.jdbc;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class JDBCConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return JDBCConfig.class;
+ }
+
+ public static class Plugin {
+ public static class MySQL {
+ /**
+ * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
+ * collected.
+ */
+ public static boolean TRACE_SQL_PARAMETERS = false;
+ /**
+ * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
+ * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
+ * <p>
+ * Set a negative number to save the complete parameter string to the tag.
+ */
+ public static int SQL_PARAMETERS_MAX_LENGTH = 512;
+ }
+
+ public static class POSTGRESQL {
+ /**
+ * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
+ * collected.
+ */
+ public static boolean TRACE_SQL_PARAMETERS = false;
+
+ /**
+ * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
+ * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
+ * <p>
+ * Set a negative number to save the complete parameter string to the tag.
+ */
+ public static int SQL_PARAMETERS_MAX_LENGTH = 512;
+ }
+
+ public static class MARIADB {
+ /**
+ * If set to true, the parameters of the sql (typically {@link java.sql.PreparedStatement}) would be
+ * collected.
+ */
+ public static boolean TRACE_SQL_PARAMETERS = false;
+
+ /**
+ * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
+ * the first {@code SQL_PARAMETERS_MAX_LENGTH} characters.
+ * <p>
+ * Set a negative number to save the complete parameter string to the tag.
+ */
+ public static int SQL_PARAMETERS_MAX_LENGTH = 512;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/PSSetterDefinitionOfJDBCInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/PSSetterDefinitionOfJDBCInstrumentation.java
index d641ca6..7886faf 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/PSSetterDefinitionOfJDBCInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/PSSetterDefinitionOfJDBCInstrumentation.java
@@ -18,14 +18,12 @@
package org.apache.skywalking.apm.plugin.jdbc;
+import java.util.Set;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.plugin.jdbc.define.Constants;
-import java.util.Set;
-
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.none;
import static org.apache.skywalking.apm.plugin.jdbc.define.Constants.PS_IGNORABLE_SETTERS;
@@ -42,7 +40,7 @@ public class PSSetterDefinitionOfJDBCInstrumentation implements InstanceMethodsI
public ElementMatcher<MethodDescription> getMethodsMatcher() {
ElementMatcher.Junction<MethodDescription> matcher = none();
- if (Config.Plugin.MySQL.TRACE_SQL_PARAMETERS || Config.Plugin.POSTGRESQL.TRACE_SQL_PARAMETERS || Config.Plugin.MARIADB.TRACE_SQL_PARAMETERS) {
+ if (JDBCConfig.Plugin.MySQL.TRACE_SQL_PARAMETERS || JDBCConfig.Plugin.POSTGRESQL.TRACE_SQL_PARAMETERS || JDBCConfig.Plugin.MARIADB.TRACE_SQL_PARAMETERS) {
final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS;
for (String setter : setters) {
matcher = matcher.or(named(setter));
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..f645eea
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.jdbc.JDBCConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java
index 4dc2417..cf54345 100644
--- a/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java
@@ -24,7 +24,7 @@ import com.networknt.handler.MiddlewareHandler;
import com.networknt.handler.OrchestrationHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.HeaderMap;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
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.ContextManager;
@@ -37,14 +37,12 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import java.lang.reflect.Method;
-
/**
* {@link HandleRequestInterceptor} creates an entry span before the execution of {@link
* com.networknt.exception.ExceptionHandler#handleRequest(HttpServerExchange)} in the I/O thread.
* <p>
- * If the {@link Config.Plugin.Light4J#TRACE_HANDLER_CHAIN} flag is set, additionally a local span is produced for each
- * {@link com.networknt.handler.MiddlewareHandler} and business handler before their respective {@link
+ * If the {@link Light4JConfig.Plugin.Light4J#TRACE_HANDLER_CHAIN} flag is set, additionally a local span is produced
+ * for each {@link com.networknt.handler.MiddlewareHandler} and business handler before their respective {@link
* com.networknt.handler.LightHttpHandler#handleRequest(HttpServerExchange)} method executes. Since {@link
* com.networknt.handler.LightHttpHandler} is implemented by various middleware and business handlers and the Light4J
* framework delegates to these in succession, a chain of {@link org.apache.skywalking.apm.agent.core.context.trace.LocalSpan}s
@@ -54,7 +52,7 @@ public class HandleRequestInterceptor implements InstanceMethodsAroundIntercepto
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) {
+ MethodInterceptResult result) {
if (isExceptionHandler(objInst)) {
HttpServerExchange exchange = (HttpServerExchange) allArguments[0];
@@ -84,7 +82,7 @@ public class HandleRequestInterceptor implements InstanceMethodsAroundIntercepto
ContextManager.stopSpan(span);
objInst.setSkyWalkingDynamicField(ContextManager.capture());
- } else if (Config.Plugin.Light4J.TRACE_HANDLER_CHAIN) {
+ } else if (Light4JConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN) {
String operationName = objInst.getClass().getName() + "." + method.getName();
ContextSnapshot snapshot = (ContextSnapshot) objInst.getSkyWalkingDynamicField();
@@ -92,7 +90,8 @@ public class HandleRequestInterceptor implements InstanceMethodsAroundIntercepto
ContextManager.continued(snapshot);
}
- } else if (Config.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(objInst) || isBusinessHandler(objInst))) {
+ } else if (Light4JConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(
+ objInst) || isBusinessHandler(objInst))) {
String operationName = objInst.getClass().getName() + "." + method.getName();
ContextManager.createLocalSpan(operationName).setComponent(ComponentsDefine.LIGHT_4J);
@@ -101,14 +100,15 @@ public class HandleRequestInterceptor implements InstanceMethodsAroundIntercepto
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) {
+ Object ret) {
if (isExceptionHandler(objInst)) {
HttpServerExchange exchange = (HttpServerExchange) allArguments[0];
- if (Config.Plugin.Light4J.TRACE_HANDLER_CHAIN && !exchange.isInIoThread()) {
+ if (Light4JConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN && !exchange.isInIoThread()) {
ContextManager.stopSpan();
}
- } else if (Config.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(objInst) || isBusinessHandler(objInst))) {
+ } else if (Light4JConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(
+ objInst) || isBusinessHandler(objInst))) {
ContextManager.stopSpan();
}
return ret;
@@ -116,13 +116,14 @@ public class HandleRequestInterceptor implements InstanceMethodsAroundIntercepto
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
private boolean isBusinessHandler(EnhancedInstance objInst) {
return !objInst.getClass().getInterfaces()[0].equals(MiddlewareHandler.class) && !objInst.getClass()
- .equals(OrchestrationHandler.class);
+ .equals(
+ OrchestrationHandler.class);
}
private boolean isMiddlewareHandler(EnhancedInstance objInst) {
diff --git a/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/Light4JConfig.java b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/Light4JConfig.java
new file mode 100644
index 0000000..d19e70f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/Light4JConfig.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugin.light4j;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class Light4JConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return Light4JConfig.class;
+ }
+
+ public static class Plugin {
+ public static class Light4J {
+ /**
+ * If true, trace all middleware/business handlers that are part of the Light4J handler chain for a request,
+ * generating a local span for each.
+ */
+ public static boolean TRACE_HANDLER_CHAIN = false;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..c9f04e1
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.light4j.Light4JConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java
index c17d94a..ff78a21 100644
--- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.jdbc.mariadb.v2;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@@ -26,12 +26,11 @@ import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
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 org.apache.skywalking.apm.plugin.jdbc.JDBCConfig;
import org.apache.skywalking.apm.plugin.jdbc.PreparedStatementParameterBuilder;
import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
-import java.lang.reflect.Method;
-
import static org.apache.skywalking.apm.plugin.jdbc.mariadb.v2.Constants.SQL_PARAMETERS;
public class PreparedStatementExecuteMethodsInterceptor implements InstanceMethodsAroundInterceptor {
@@ -45,13 +44,13 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
return;
}
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject
- .getStatementName()), connectInfo.getDatabasePeer());
+ .getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
- if (Config.Plugin.MARIADB.TRACE_SQL_PARAMETERS) {
+ if (JDBCConfig.Plugin.MARIADB.TRACE_SQL_PARAMETERS) {
final Object[] parameters = cacheObject.getParameters();
if (parameters != null && parameters.length > 0) {
int maxIndex = cacheObject.getMaxIndex();
@@ -87,9 +86,9 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
private String getParameterString(Object[] parameters, int maxIndex) {
return new PreparedStatementParameterBuilder()
- .setParameters(parameters)
- .setMaxIndex(maxIndex)
- .setMaxLength(Config.Plugin.MARIADB.SQL_PARAMETERS_MAX_LENGTH)
- .build();
+ .setParameters(parameters)
+ .setMaxIndex(maxIndex)
+ .setMaxLength(JDBCConfig.Plugin.MARIADB.SQL_PARAMETERS_MAX_LENGTH)
+ .build();
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java
index 8742842..73f6e7e 100644
--- a/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/mariadb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mariadb/v2/PreparedStatementExecuteMethodsInterceptorTest.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.jdbc.mariadb.v2;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
@@ -27,9 +27,10 @@ import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
-import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
import org.apache.skywalking.apm.agent.test.tools.SpanAssert;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.apache.skywalking.apm.plugin.jdbc.JDBCConfig;
import org.apache.skywalking.apm.plugin.jdbc.JDBCPreparedStatementSetterInterceptor;
import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
@@ -41,8 +42,6 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import java.lang.reflect.Method;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;
@@ -73,7 +72,7 @@ public class PreparedStatementExecuteMethodsInterceptorTest {
@Before
public void setUp() {
- Config.Plugin.MARIADB.TRACE_SQL_PARAMETERS = true;
+ JDBCConfig.Plugin.MARIADB.TRACE_SQL_PARAMETERS = true;
preparedStatementSetterInterceptor = new JDBCPreparedStatementSetterInterceptor();
serviceMethodInterceptor = new PreparedStatementExecuteMethodsInterceptor();
@@ -88,11 +87,19 @@ public class PreparedStatementExecuteMethodsInterceptorTest {
@Test
public void testExecutePreparedStatement() throws Throwable {
- preparedStatementSetterInterceptor.beforeMethod(objectInstance, method, new Object[]{1, "abcd"}, null, null);
- preparedStatementSetterInterceptor.beforeMethod(objectInstance, method, new Object[]{2, "efgh"}, null, null);
-
- serviceMethodInterceptor.beforeMethod(objectInstance, method, new Object[]{SQL}, null, null);
- serviceMethodInterceptor.afterMethod(objectInstance, method, new Object[]{SQL}, null, null);
+ preparedStatementSetterInterceptor.beforeMethod(
+ objectInstance, method, new Object[] {
+ 1,
+ "abcd"
+ }, null, null);
+ preparedStatementSetterInterceptor.beforeMethod(
+ objectInstance, method, new Object[] {
+ 2,
+ "efgh"
+ }, null, null);
+
+ serviceMethodInterceptor.beforeMethod(objectInstance, method, new Object[] {SQL}, null, null);
+ serviceMethodInterceptor.afterMethod(objectInstance, method, new Object[] {SQL}, null, null);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment segment = segmentStorage.getTraceSegments().get(0);
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v2/MongoDBCollectionMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mongodb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v2/MongoDBCollectionMethodInterceptorTest.java
index 49f352f..8fb7267 100644
--- a/apm-sniffer/apm-sdk-plugin/mongodb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v2/MongoDBCollectionMethodInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v2/MongoDBCollectionMethodInterceptorTest.java
@@ -22,7 +22,6 @@ import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
@@ -74,13 +73,8 @@ public class MongoDBCollectionMethodInterceptorTest {
})
@Before
public void setUp() throws Exception {
-
interceptor = new MongoDBCollectionMethodInterceptor();
-
- Config.Plugin.MongoDB.TRACE_PARAM = true;
-
when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn("127.0.0.1:27017");
-
}
@Test
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoConfig.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoConfig.java
new file mode 100644
index 0000000..1aefa9e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/MongoConfig.java
@@ -0,0 +1,46 @@
+/*
+ * 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.plugin.mongodb.v3;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class MongoConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return MongoConfig.class;
+ }
+
+ public static class Plugin {
+ public static class MongoDB {
+ /**
+ * If true, trace all the parameters in MongoDB access, default is false. Only trace the operation, not
+ * include parameters.
+ */
+ public static boolean TRACE_PARAM = false;
+
+ /**
+ * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
+ * the first {@code FILTER_LENGTH_LIMIT} characters.
+ * <p>
+ * Set a negative number to save the complete parameter string to the tag.
+ */
+ public static int FILTER_LENGTH_LIMIT = 256;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoOperationHelper.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoOperationHelper.java
index 42e5ecd..2adbe80 100644
--- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoOperationHelper.java
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoOperationHelper.java
@@ -39,10 +39,9 @@ import com.mongodb.operation.MapReduceToCollectionOperation;
import com.mongodb.operation.MapReduceWithInlineResultsOperation;
import com.mongodb.operation.MixedBulkWriteOperation;
import com.mongodb.operation.UpdateOperation;
-import org.apache.skywalking.apm.agent.core.conf.Config;
-import org.bson.BsonDocument;
-
import java.util.List;
+import org.apache.skywalking.apm.plugin.mongodb.v3.MongoConfig;
+import org.bson.BsonDocument;
@SuppressWarnings({
"deprecation",
@@ -126,7 +125,7 @@ public class MongoOperationHelper {
} else if (request instanceof UpdateRequest) {
params.append(((UpdateRequest) request).getFilter()).append(",");
}
- final int filterLengthLimit = Config.Plugin.MongoDB.FILTER_LENGTH_LIMIT;
+ final int filterLengthLimit = MongoConfig.Plugin.MongoDB.FILTER_LENGTH_LIMIT;
if (filterLengthLimit > 0 && params.length() > filterLengthLimit) {
return params.substring(0, filterLengthLimit) + "...";
}
@@ -136,7 +135,7 @@ public class MongoOperationHelper {
private static String limitFilter(String filter) {
final StringBuilder params = new StringBuilder();
- final int filterLengthLimit = Config.Plugin.MongoDB.FILTER_LENGTH_LIMIT;
+ final int filterLengthLimit = MongoConfig.Plugin.MongoDB.FILTER_LENGTH_LIMIT;
if (filterLengthLimit > 0 && filter.length() > filterLengthLimit) {
return params.append(filter, 0, filterLengthLimit).append("...").toString();
} else {
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoSpanHelper.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoSpanHelper.java
index 418707e..f163632 100644
--- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoSpanHelper.java
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mongodb/v3/support/MongoSpanHelper.java
@@ -18,13 +18,13 @@
package org.apache.skywalking.apm.plugin.mongodb.v3.support;
-import org.apache.skywalking.apm.agent.core.conf.Config;
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.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.apache.skywalking.apm.plugin.mongodb.v3.MongoConfig;
public class MongoSpanHelper {
@@ -32,12 +32,13 @@ public class MongoSpanHelper {
}
public static void createExitSpan(String executeMethod, String remotePeer, Object operation) {
- AbstractSpan span = ContextManager.createExitSpan(MongoConstants.MONGO_DB_OP_PREFIX + executeMethod, new ContextCarrier(), remotePeer);
+ AbstractSpan span = ContextManager.createExitSpan(
+ MongoConstants.MONGO_DB_OP_PREFIX + executeMethod, new ContextCarrier(), remotePeer);
span.setComponent(ComponentsDefine.MONGO_DRIVER);
Tags.DB_TYPE.set(span, MongoConstants.DB_TYPE);
SpanLayer.asDB(span);
- if (Config.Plugin.MongoDB.TRACE_PARAM) {
+ if (MongoConfig.Plugin.MongoDB.TRACE_PARAM) {
Tags.DB_STATEMENT.set(span, executeMethod + " " + MongoOperationHelper.getTraceParam(operation));
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..04d04b3
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.mongodb.v3.MongoConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v30/MongoDBInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v30/MongoDBInterceptorTest.java
index e0b32b2..af91a78 100644
--- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v30/MongoDBInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v30/MongoDBInterceptorTest.java
@@ -23,7 +23,6 @@ import com.mongodb.MongoNamespace;
import com.mongodb.operation.FindOperation;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
@@ -37,6 +36,7 @@ import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
import org.apache.skywalking.apm.agent.test.tools.SpanAssert;
import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.apache.skywalking.apm.plugin.mongodb.v3.MongoConfig;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.codecs.Decoder;
@@ -82,7 +82,7 @@ public class MongoDBInterceptorTest {
interceptor = new MongoDBInterceptor();
- Config.Plugin.MongoDB.TRACE_PARAM = true;
+ MongoConfig.Plugin.MongoDB.TRACE_PARAM = true;
when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn("127.0.0.1:27017");
@@ -111,7 +111,8 @@ public class MongoDBInterceptorTest {
@Test
public void testInterceptWithException() throws Throwable {
interceptor.beforeMethod(enhancedInstance, getExecuteMethod(), arguments, argumentTypes, null);
- interceptor.handleMethodException(enhancedInstance, getExecuteMethod(), arguments, argumentTypes, new RuntimeException());
+ interceptor.handleMethodException(
+ enhancedInstance, getExecuteMethod(), arguments, argumentTypes, new RuntimeException());
interceptor.afterMethod(enhancedInstance, getExecuteMethod(), arguments, argumentTypes, null);
MatcherAssert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v37/MongoDBOperationExecutorInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v37/MongoDBOperationExecutorInterceptorTest.java
index fe06f4f..332c012 100644
--- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v37/MongoDBOperationExecutorInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/mongodb/v3/interceptor/v37/MongoDBOperationExecutorInterceptorTest.java
@@ -25,7 +25,6 @@ import com.mongodb.operation.FindOperation;
import com.mongodb.operation.WriteOperation;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
@@ -39,6 +38,7 @@ import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
import org.apache.skywalking.apm.agent.test.tools.SpanAssert;
import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.apache.skywalking.apm.plugin.mongodb.v3.MongoConfig;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.codecs.Decoder;
@@ -81,7 +81,7 @@ public class MongoDBOperationExecutorInterceptorTest {
interceptor = new MongoDBOperationExecutorInterceptor();
- Config.Plugin.MongoDB.TRACE_PARAM = true;
+ MongoConfig.Plugin.MongoDB.TRACE_PARAM = true;
when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn("127.0.0.1:27017");
@@ -110,7 +110,8 @@ public class MongoDBOperationExecutorInterceptorTest {
@Test
public void testInterceptWithException() throws Throwable {
interceptor.beforeMethod(enhancedInstance, getMethod(), arguments, argumentTypes, null);
- interceptor.handleMethodException(enhancedInstance, getMethod(), arguments, argumentTypes, new RuntimeException());
+ interceptor.handleMethodException(
+ enhancedInstance, getMethod(), arguments, argumentTypes, new RuntimeException());
interceptor.afterMethod(enhancedInstance, getMethod(), arguments, argumentTypes, null);
MatcherAssert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java
index 27f4c6b..ba7c05d 100644
--- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/PreparedStatementExecuteMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.jdbc.mysql;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@@ -26,12 +26,11 @@ import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
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 org.apache.skywalking.apm.plugin.jdbc.JDBCConfig;
import org.apache.skywalking.apm.plugin.jdbc.PreparedStatementParameterBuilder;
import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
-import java.lang.reflect.Method;
-
import static org.apache.skywalking.apm.plugin.jdbc.mysql.Constants.SQL_PARAMETERS;
public class PreparedStatementExecuteMethodsInterceptor implements InstanceMethodsAroundInterceptor {
@@ -49,14 +48,15 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
*/
if (cacheObject != null && cacheObject.getConnectionInfo() != null) {
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
- AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject
+ AbstractSpan span = ContextManager.createExitSpan(
+ buildOperationName(connectInfo, method.getName(), cacheObject
.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
- if (Config.Plugin.MySQL.TRACE_SQL_PARAMETERS) {
+ if (JDBCConfig.Plugin.MySQL.TRACE_SQL_PARAMETERS) {
final Object[] parameters = cacheObject.getParameters();
if (parameters != null && parameters.length > 0) {
int maxIndex = cacheObject.getMaxIndex();
@@ -94,9 +94,9 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
private String getParameterString(Object[] parameters, int maxIndex) {
return new PreparedStatementParameterBuilder()
- .setParameters(parameters)
- .setMaxIndex(maxIndex)
- .setMaxLength(Config.Plugin.MySQL.SQL_PARAMETERS_MAX_LENGTH)
- .build();
+ .setParameters(parameters)
+ .setMaxIndex(maxIndex)
+ .setMaxLength(JDBCConfig.Plugin.MySQL.SQL_PARAMETERS_MAX_LENGTH)
+ .build();
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java
index 151c37e..efac567 100755
--- a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/PreparedStatementExecuteMethodsInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.jdbc.postgresql;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.StringTag;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
@@ -27,12 +27,11 @@ import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
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 org.apache.skywalking.apm.plugin.jdbc.JDBCConfig;
import org.apache.skywalking.apm.plugin.jdbc.PreparedStatementParameterBuilder;
import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
-import java.lang.reflect.Method;
-
/**
* {@link PreparedStatementExecuteMethodsInterceptor} create the exit span when the client call the interceptor
* methods.
@@ -46,14 +45,15 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
Class<?>[] argumentsTypes, MethodInterceptResult result) {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
- AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo
+ AbstractSpan span = ContextManager.createExitSpan(
+ buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo
.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
- if (Config.Plugin.POSTGRESQL.TRACE_SQL_PARAMETERS) {
+ if (JDBCConfig.Plugin.POSTGRESQL.TRACE_SQL_PARAMETERS) {
final Object[] parameters = cacheObject.getParameters();
if (parameters != null && parameters.length > 0) {
int maxIndex = cacheObject.getMaxIndex();
@@ -90,9 +90,9 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
private String getParameterString(Object[] parameters, int maxIndex) {
return new PreparedStatementParameterBuilder()
- .setParameters(parameters)
- .setMaxIndex(maxIndex)
- .setMaxLength(Config.Plugin.POSTGRESQL.SQL_PARAMETERS_MAX_LENGTH)
- .build();
+ .setParameters(parameters)
+ .setMaxIndex(maxIndex)
+ .setMaxLength(JDBCConfig.Plugin.POSTGRESQL.SQL_PARAMETERS_MAX_LENGTH)
+ .build();
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptor.java
index b819763..e4659d7 100644
--- a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptor.java
@@ -18,7 +18,12 @@
package org.apache.skywalking.apm.plugin.solrj;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
@@ -44,13 +49,6 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.NamedList;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
private static final String DB_TYPE = "Solr";
@@ -75,7 +73,7 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
SolrRequest<?> request = (SolrRequest<?>) allArguments[0];
SolrjInstance instance = (SolrjInstance) objInst.getSkyWalkingDynamicField();
@@ -101,21 +99,21 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
deleteBy = ur.getDeleteQuery();
}
if (deleteBy == null) {
- deleteBy = new ArrayList<String>();
+ deleteBy = new ArrayList<>();
}
String operator = getOperatorNameWithAction(collection, request.getPath(), actionName);
span = getSpan(operator, instance.getRemotePeer());
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
span.tag(Tags.DB_STATEMENT, deleteBy.toString());
}
} else {
String operator = getOperatorNameWithAction(collection, request.getPath(), "ADD");
span = getSpan(operator, instance.getRemotePeer());
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
span.tag(SolrjTags.TAG_DOCS_SIZE, String.valueOf(documents.size()));
}
}
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
span.tag(SolrjTags.TAG_COMMIT_WITHIN, String.valueOf(ur.getCommitWithin()));
}
} else {
@@ -125,11 +123,12 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
String operator = getOperatorNameWithAction(collection, request.getPath(), action.name());
AbstractSpan span = getSpan(operator, instance.getRemotePeer());
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
if (action == AbstractUpdateRequest.ACTION.COMMIT) {
span.tag(SolrjTags.TAG_SOFT_COMMIT, params.get(UpdateParams.SOFT_COMMIT, ""));
} else {
- span.tag(SolrjTags.TAG_MAX_OPTIMIZE_SEGMENTS, params.get(UpdateParams.MAX_OPTIMIZE_SEGMENTS, "1"));
+ span.tag(
+ SolrjTags.TAG_MAX_OPTIMIZE_SEGMENTS, params.get(UpdateParams.MAX_OPTIMIZE_SEGMENTS, "1"));
}
}
}
@@ -139,7 +138,7 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
span.tag(SolrjTags.TAG_START, params.get(CommonParams.START, "0"));
span.tag(SolrjTags.TAG_QT, params.get(CommonParams.QT, request.getPath()));
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
span.tag(Tags.DB_STATEMENT, toQueryString(params));
}
} else {
@@ -150,7 +149,7 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
@Override
@SuppressWarnings("unchecked")
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
if (!ContextManager.isActive()) {
return ret;
}
@@ -175,7 +174,7 @@ public class SolrClientInterceptor implements InstanceMethodsAroundInterceptor,
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
if (ContextManager.isActive()) {
AbstractSpan span = ContextManager.activeSpan();
int code = 500;
diff --git a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrJConfig.java b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrJConfig.java
new file mode 100644
index 0000000..2bfd027
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/solrj/SolrJConfig.java
@@ -0,0 +1,43 @@
+/*
+ * 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.plugin.solrj;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class SolrJConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return SolrJConfig.class;
+ }
+
+ public static class Plugin {
+ public static class SolrJ {
+ /**
+ * If true, trace all the query parameters(include deleteByIds and deleteByQuery) in Solr query request,
+ * default is false.
+ */
+ public static boolean TRACE_STATEMENT = false;
+
+ /**
+ * If true, trace all the operation parameters in Solr request, default is false.
+ */
+ public static boolean TRACE_OPS_PARAMS = false;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..c617794
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.solrj.SolrJConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptorTest.java
index 93381f7..ba3b662 100644
--- a/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/solrj-7.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/solrj/SolrClientInterceptorTest.java
@@ -21,7 +21,6 @@ package org.apache.skywalking.apm.plugin.solrj;
import com.google.common.collect.Lists;
import java.lang.reflect.Method;
import java.util.List;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
@@ -104,9 +103,6 @@ public class SolrClientInterceptorTest {
header = new NamedList<Object>();
header.add("status", 0);
header.add("QTime", 5);
-
- // Config.Plugin.SolrJ.TRACE_STATEMENT = true;
- // Config.Plugin.SolrJ.TRACE_OPS_PARAMS = true;
}
@Test
@@ -143,10 +139,10 @@ public class SolrClientInterceptorTest {
AbstractTracingSpan span = spans.get(0);
int pox = 0;
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
SpanAssert.assertTag(span, ++pox, "100");
}
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
SpanAssert.assertTag(span, ++pox, "-1");
}
spanCommonAssert(span, pox, "solrJ/collection/update/ADD");
@@ -155,7 +151,8 @@ public class SolrClientInterceptorTest {
@Test
public void testUpdateWithCommit() throws Throwable {
final boolean softCommit = false;
- AbstractUpdateRequest request = (new UpdateRequest()).setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, false);
+ AbstractUpdateRequest request = (new UpdateRequest()).setAction(
+ AbstractUpdateRequest.ACTION.COMMIT, true, true, false);
arguments = new Object[] {
request,
null,
@@ -172,7 +169,7 @@ public class SolrClientInterceptorTest {
int start = 0;
AbstractTracingSpan span = spans.get(0);
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
SpanAssert.assertTag(span, ++start, String.valueOf(softCommit));
}
spanCommonAssert(span, start, "solrJ/collection/update/COMMIT");
@@ -181,7 +178,8 @@ public class SolrClientInterceptorTest {
@Test
public void testUpdateWithOptimize() throws Throwable {
final int maxSegments = 1;
- AbstractUpdateRequest request = (new UpdateRequest()).setAction(AbstractUpdateRequest.ACTION.OPTIMIZE, false, true, maxSegments);
+ AbstractUpdateRequest request = (new UpdateRequest()).setAction(
+ AbstractUpdateRequest.ACTION.OPTIMIZE, false, true, maxSegments);
arguments = new Object[] {
request,
null,
@@ -198,7 +196,7 @@ public class SolrClientInterceptorTest {
AbstractTracingSpan span = spans.get(0);
int start = 0;
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
SpanAssert.assertTag(span, ++start, String.valueOf(maxSegments));
}
spanCommonAssert(span, start, "solrJ/collection/update/OPTIMIZE");
@@ -312,7 +310,10 @@ public class SolrClientInterceptorTest {
response.add("responseHeader", header);
interceptor.beforeMethod(enhancedInstance, method, arguments, argumentType, null);
- interceptor.handleMethodException(enhancedInstance, method, arguments, argumentType, new SolrException(SolrException.ErrorCode.SERVER_ERROR, "for test", new Exception()));
+ interceptor.handleMethodException(
+ enhancedInstance, method, arguments, argumentType,
+ new SolrException(SolrException.ErrorCode.SERVER_ERROR, "for test", new Exception())
+ );
interceptor.afterMethod(enhancedInstance, method, arguments, argumentType, response);
List<TraceSegment> segments = segmentStorage.getTraceSegments();
@@ -332,7 +333,7 @@ public class SolrClientInterceptorTest {
SpanAssert.assertTag(span, 2, qt);
int start = 3;
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
start++;
}
SpanAssert.assertTag(span, start++, "5");
@@ -361,10 +362,10 @@ public class SolrClientInterceptorTest {
SpanAssert.assertTag(span, 0, "Solr");
int start = 0;
- if (Config.Plugin.SolrJ.TRACE_STATEMENT) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_STATEMENT) {
SpanAssert.assertTag(span, ++start, statement);
}
- if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
+ if (SolrJConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
SpanAssert.assertTag(span, ++start, "-1");
}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/SpringMVCConfig.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/SpringMVCConfig.java
new file mode 100644
index 0000000..555fba6
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/SpringMVCConfig.java
@@ -0,0 +1,53 @@
+/*
+ * 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.plugin.spring.mvc.commons;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class SpringMVCConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return SpringMVCConfig.class;
+ }
+
+ public static class Plugin {
+ 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;
+
+ /**
+ * This config item controls that whether the SpringMVC plugin should collect the parameters of the
+ * request.
+ */
+ public static boolean COLLECT_HTTP_PARAMS = false;
+ }
+
+ public static class Http {
+ /**
+ * When either {@link Plugin.SpringMVC#COLLECT_HTTP_PARAMS} is enabled, how many characters to keep and send
+ * to the OAP backend, use negative values to keep and send the complete parameters, NB. this config item is
+ * added for the sake of performance
+ */
+ public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
index 669d2e8..5f59880 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Method;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
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.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@@ -36,6 +35,7 @@ import org.apache.skywalking.apm.agent.core.util.CollectionUtil;
import org.apache.skywalking.apm.agent.core.util.MethodUtil;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache;
+import org.apache.skywalking.apm.plugin.spring.mvc.commons.SpringMVCConfig;
import org.apache.skywalking.apm.plugin.spring.mvc.commons.exception.IllegalMethodStackDepthException;
import org.apache.skywalking.apm.plugin.spring.mvc.commons.exception.ServletResponseNotFoundException;
import org.apache.skywalking.apm.util.StringUtil;
@@ -55,7 +55,8 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
private static final String GET_STATUS_METHOD = "getStatus";
static {
- IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(AbstractMethodInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
+ IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(
+ AbstractMethodInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
}
public abstract String getRequestURL(Method method);
@@ -64,7 +65,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
Boolean forwardRequestFlag = (Boolean) ContextManager.getRuntimeContext().get(FORWARD_REQUEST_FLAG);
/**
@@ -76,7 +77,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
}
String operationName;
- if (Config.Plugin.SpringMVC.USE_QUALIFIED_NAME_AS_ENDPOINT_NAME) {
+ if (SpringMVCConfig.Plugin.SpringMVC.USE_QUALIFIED_NAME_AS_ENDPOINT_NAME) {
operationName = MethodUtil.generateOperationName(method);
} else {
EnhanceRequireObjectCache pathMappingCache = (EnhanceRequireObjectCache) objInst.getSkyWalkingDynamicField();
@@ -108,7 +109,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
span.setComponent(ComponentsDefine.SPRING_MVC_ANNOTATION);
SpanLayer.asHttp(span);
- if (Config.Plugin.SpringMVC.COLLECT_HTTP_PARAMS) {
+ if (SpringMVCConfig.Plugin.SpringMVC.COLLECT_HTTP_PARAMS) {
collectHttpParam(request, span);
}
@@ -140,7 +141,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
Boolean forwardRequestFlag = (Boolean) ContextManager.getRuntimeContext().get(FORWARD_REQUEST_FLAG);
/**
* Spring MVC plugin do nothing if current request is forward request.
@@ -165,7 +166,8 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
if (stackDepth.depth() == 0) {
HttpServletResponse response = (HttpServletResponse) ContextManager.getRuntimeContext()
- .get(RESPONSE_KEY_IN_RUNTIME_CONTEXT);
+ .get(
+ RESPONSE_KEY_IN_RUNTIME_CONTEXT);
if (response == null) {
throw new ServletResponseNotFoundException();
}
@@ -181,7 +183,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
}
// Active HTTP parameter collection automatically in the profiling context.
- if (!Config.Plugin.SpringMVC.COLLECT_HTTP_PARAMS && span.isProfiling()) {
+ if (!SpringMVCConfig.Plugin.SpringMVC.COLLECT_HTTP_PARAMS && span.isProfiling()) {
collectHttpParam(request, span);
}
@@ -193,7 +195,7 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
@@ -201,7 +203,8 @@ public abstract class AbstractMethodInterceptor implements InstanceMethodsAround
final Map<String, String[]> parameterMap = request.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
String tagValue = CollectionUtil.toString(parameterMap);
- tagValue = Config.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ? StringUtil.cut(tagValue, Config.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) : tagValue;
+ tagValue = SpringMVCConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ?
+ StringUtil.cut(tagValue, SpringMVCConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) : tagValue;
Tags.HTTP.PARAMS.set(span, tagValue);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..181b88a
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.spring.mvc.commons.SpringMVCConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatConfig.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatConfig.java
new file mode 100644
index 0000000..d6872af
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatConfig.java
@@ -0,0 +1,46 @@
+/*
+ * 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.plugin.tomcat78x;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class TomcatConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return TomcatConfig.class;
+ }
+
+ public static class Plugin {
+ public static class Tomcat {
+ /**
+ * This config item controls that whether the Tomcat plugin should collect the parameters of the request.
+ */
+ public static boolean COLLECT_HTTP_PARAMS = false;
+ }
+
+ public static class Http {
+ /**
+ * When either {@link Tomcat#COLLECT_HTTP_PARAMS} is enabled, how
+ * many characters to keep and send to the OAP backend, use negative values to keep and send the complete
+ * parameters, NB. this config item is added for the sake of performance
+ */
+ public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
index aa37060..8f47aff 100644
--- a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/TomcatInvokeInterceptor.java
@@ -18,15 +18,13 @@
package org.apache.skywalking.apm.plugin.tomcat78x;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.connector.Request;
-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.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@@ -55,7 +53,8 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
private static final String GET_STATUS_METHOD = "getStatus";
static {
- IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(TomcatInvokeInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
+ IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(
+ TomcatInvokeInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
}
/**
@@ -66,7 +65,7 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
*/
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
Request request = (Request) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
@@ -82,14 +81,14 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
span.setComponent(ComponentsDefine.TOMCAT);
SpanLayer.asHttp(span);
- if (Config.Plugin.Tomcat.COLLECT_HTTP_PARAMS) {
+ if (TomcatConfig.Plugin.Tomcat.COLLECT_HTTP_PARAMS) {
collectHttpParam(request, span);
}
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
Request request = (Request) allArguments[0];
HttpServletResponse response = (HttpServletResponse) allArguments[1];
@@ -99,7 +98,7 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
}
// Active HTTP parameter collection automatically in the profiling context.
- if (!Config.Plugin.Tomcat.COLLECT_HTTP_PARAMS && span.isProfiling()) {
+ if (!TomcatConfig.Plugin.Tomcat.COLLECT_HTTP_PARAMS && span.isProfiling()) {
collectHttpParam(request, span);
}
ContextManager.stopSpan();
@@ -109,7 +108,7 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
AbstractSpan span = ContextManager.activeSpan();
span.log(t);
span.errorOccurred();
@@ -126,7 +125,9 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
if (!parameterMap.isEmpty()) {
String tagValue = CollectionUtil.toString(parameterMap);
- tagValue = Config.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ? StringUtil.cut(tagValue, Config.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) : tagValue;
+ tagValue = TomcatConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ?
+ StringUtil.cut(tagValue, TomcatConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) :
+ tagValue;
Tags.HTTP.PARAMS.set(span, tagValue);
}
}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..133f448
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.tomcat78x.TomcatConfig
\ No newline at end of file
diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/ToolkitConfigService.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/ToolkitConfigService.java
new file mode 100644
index 0000000..97a2c02
--- /dev/null
+++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/ToolkitConfigService.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class ToolkitConfigService implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return ToolkitConfigService.class;
+ }
+
+ public static class Plugin {
+ public static class Toolkit {
+ /**
+ * If true, the fully qualified method name will be used as the operation name instead of the given
+ * operation name, default is false.
+ */
+ public static boolean USE_QUALIFIED_NAME_AS_OPERATION_NAME = false;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java
index 95c4fb5..ae1cb67 100644
--- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java
+++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/TraceAnnotationMethodInterceptor.java
@@ -20,19 +20,18 @@ package org.apache.skywalking.apm.toolkit.activation.trace;
import java.lang.reflect.Method;
import java.util.Map;
-
-import org.apache.skywalking.apm.agent.core.conf.Config;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.toolkit.activation.util.TagUtil;
-import org.apache.skywalking.apm.agent.core.util.CustomizeExpression;
-import org.apache.skywalking.apm.toolkit.trace.Tag;
-import org.apache.skywalking.apm.toolkit.trace.Tags;
-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.trace.AbstractSpan;
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 org.apache.skywalking.apm.agent.core.util.CustomizeExpression;
import org.apache.skywalking.apm.agent.core.util.MethodUtil;
+import org.apache.skywalking.apm.toolkit.activation.ToolkitConfigService;
+import org.apache.skywalking.apm.toolkit.activation.util.TagUtil;
+import org.apache.skywalking.apm.toolkit.trace.Tag;
+import org.apache.skywalking.apm.toolkit.trace.Tags;
+import org.apache.skywalking.apm.toolkit.trace.Trace;
/**
* {@link TraceAnnotationMethodInterceptor} create a local span and set the operation name which fetch from
@@ -42,10 +41,10 @@ import org.apache.skywalking.apm.agent.core.util.MethodUtil;
public class TraceAnnotationMethodInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
Trace trace = method.getAnnotation(Trace.class);
String operationName = trace.operationName();
- if (operationName.length() == 0 || Config.Plugin.Toolkit.USE_QUALIFIED_NAME_AS_OPERATION_NAME) {
+ if (operationName.length() == 0 || ToolkitConfigService.Plugin.Toolkit.USE_QUALIFIED_NAME_AS_OPERATION_NAME) {
operationName = MethodUtil.generateOperationName(method);
}
@@ -69,7 +68,7 @@ public class TraceAnnotationMethodInterceptor implements InstanceMethodsAroundIn
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
try {
if (ret == null) {
return ret;
@@ -96,7 +95,7 @@ public class TraceAnnotationMethodInterceptor implements InstanceMethodsAroundIn
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}
diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..c7f3622
--- /dev/null
+++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.toolkit.activation.ToolkitConfigService
\ No newline at end of file
diff --git a/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/JDKThreadingConfig.java b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/JDKThreadingConfig.java
new file mode 100644
index 0000000..7bc3e11
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/JDKThreadingConfig.java
@@ -0,0 +1,40 @@
+/*
+ * 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.plugin.jdk.threading;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class JDKThreadingConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return JDKThreadingConfig.class;
+ }
+
+ public static class Plugin {
+ public static class JdkThreading {
+
+ /**
+ * Threading classes ({@link java.lang.Runnable} and {@link java.util.concurrent.Callable} and their
+ * subclasses, including anonymous inner classes) whose name matches any one of the {@code
+ * THREADING_CLASS_PREFIXES} (splitted by ,) will be instrumented
+ */
+ public static String THREADING_CLASS_PREFIXES = "";
+ }
+ }
+}
diff --git a/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/ThreadingConfig.java b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/ThreadingConfig.java
index fb4736f..b3b181f 100644
--- a/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/ThreadingConfig.java
+++ b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdk/threading/ThreadingConfig.java
@@ -20,13 +20,11 @@ package org.apache.skywalking.apm.plugin.jdk.threading;
import java.util.ArrayList;
import java.util.List;
-
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.plugin.match.IndirectMatch;
-import org.apache.skywalking.apm.agent.core.plugin.match.logical.LogicalMatchOperation;
import org.apache.skywalking.apm.agent.core.plugin.match.PrefixMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.logical.LogicalMatchOperation;
import static org.apache.skywalking.apm.agent.core.plugin.match.PrefixMatch.nameStartsWith;
@@ -34,7 +32,7 @@ public class ThreadingConfig {
private static final ILog LOGGER = LogManager.getLogger(ThreadingConfig.class);
public static IndirectMatch prefixesMatchesForJdkThreading() {
- final String jointPrefixes = Config.Plugin.JdkThreading.THREADING_CLASS_PREFIXES;
+ final String jointPrefixes = JDKThreadingConfig.Plugin.JdkThreading.THREADING_CLASS_PREFIXES;
if (jointPrefixes == null || jointPrefixes.trim().isEmpty()) {
return null;
diff --git a/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..ac5be8a
--- /dev/null
+++ b/apm-sniffer/bootstrap-plugins/jdk-threading-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.jdk.threading.JDKThreadingConfig
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/ConfigService.java b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/ConfigService.java
new file mode 100644
index 0000000..8b59be7
--- /dev/null
+++ b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/ConfigService.java
@@ -0,0 +1,45 @@
+/*
+ * 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.plugin.customize.conf;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class ConfigService implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return ConfigService.class;
+ }
+
+ public static class Plugin {
+ public static class Customize {
+ /**
+ * Custom enhancement class configuration file path, recommended to use an absolute path.
+ */
+ public static String ENHANCE_FILE = "";
+
+ /**
+ * Some information after custom enhancements, this configuration is used by the custom enhancement plugin.
+ * And using Map CONTEXT for avoiding classloader isolation issue.
+ */
+ public static Map<String, Object> CONTEXT = new HashMap<>();
+ }
+ }
+}
diff --git a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/CustomizeConfiguration.java b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/CustomizeConfiguration.java
index 11ab13c..a22ad1e 100644
--- a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/CustomizeConfiguration.java
+++ b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/conf/CustomizeConfiguration.java
@@ -30,7 +30,6 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine;
@@ -80,7 +79,7 @@ public enum CustomizeConfiguration {
*/
private List<Map<String, Object>> resolver() throws ParserConfigurationException, IOException, SAXException {
List<Map<String, Object>> customizeMethods = new ArrayList<Map<String, Object>>();
- File file = new File(Config.Plugin.Customize.ENHANCE_FILE);
+ File file = new File(ConfigService.Plugin.Customize.ENHANCE_FILE);
if (file.exists() && file.isFile()) {
NodeList classNodeList = resolverFileClassDesc(file);
resolverClassNodeList(classNodeList, customizeMethods);
@@ -140,26 +139,30 @@ public enum CustomizeConfiguration {
Map<String, Object> configuration = new HashMap<String, Object>();
if (methodDesc.getAttributes().getNamedItem(Constants.XML_ELEMENT_OPERATION_NAME) != null) {
MethodConfiguration.setOperationName(configuration, methodDesc.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_OPERATION_NAME)
+ .getNamedItem(
+ Constants.XML_ELEMENT_OPERATION_NAME)
.getNodeValue());
}
if (methodDesc.getAttributes().getNamedItem(Constants.XML_ELEMENT_CLOSE_BEFORE_METHOD) != null) {
MethodConfiguration.setCloseBeforeMethod(configuration, Boolean.valueOf(methodDesc.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_CLOSE_BEFORE_METHOD)
+ .getNamedItem(
+ Constants.XML_ELEMENT_CLOSE_BEFORE_METHOD)
.getNodeValue()));
} else {
MethodConfiguration.setCloseBeforeMethod(configuration, false);
}
if (methodDesc.getAttributes().getNamedItem(Constants.XML_ELEMENT_CLOSE_AFTER_METHOD) != null) {
MethodConfiguration.setCloseAfterMethod(configuration, Boolean.valueOf(methodDesc.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_CLOSE_AFTER_METHOD)
+ .getNamedItem(
+ Constants.XML_ELEMENT_CLOSE_AFTER_METHOD)
.getNodeValue()));
} else {
MethodConfiguration.setCloseAfterMethod(configuration, false);
}
if (methodDesc.getAttributes().getNamedItem(Constants.XML_ELEMENT_METHOD_IS_STATIC) != null) {
MethodConfiguration.setStatic(configuration, Boolean.valueOf(methodDesc.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_METHOD_IS_STATIC)
+ .getNamedItem(
+ Constants.XML_ELEMENT_METHOD_IS_STATIC)
.getNodeValue()));
}
setAdvancedField(configuration, methodDesc);
@@ -183,14 +186,16 @@ public enum CustomizeConfiguration {
MethodConfiguration.addOperationNameSuffixes(configuration, methodContentNode.getTextContent());
}
if (Constants.XML_ELEMENT_TAG.equals(methodContentNode.getNodeName())) {
- MethodConfiguration.addTag(configuration, methodContentNode.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_KEY)
- .getNodeValue(), methodContentNode.getTextContent());
+ MethodConfiguration.addTag(
+ configuration, methodContentNode.getAttributes()
+ .getNamedItem(Constants.XML_ELEMENT_KEY)
+ .getNodeValue(), methodContentNode.getTextContent());
}
if (Constants.XML_ELEMENT_LOG.equals(methodContentNode.getNodeName())) {
- MethodConfiguration.addLog(configuration, methodContentNode.getAttributes()
- .getNamedItem(Constants.XML_ELEMENT_KEY)
- .getNodeValue(), methodContentNode.getTextContent());
+ MethodConfiguration.addLog(
+ configuration, methodContentNode.getAttributes()
+ .getNamedItem(Constants.XML_ELEMENT_KEY)
+ .getNodeValue(), methodContentNode.getTextContent());
}
}
}
@@ -206,16 +211,18 @@ public enum CustomizeConfiguration {
* @return configuration of method.
*/
private Map<String, Object> resolverClassAndMethod(String className, String methodDesc,
- Map<String, Object> configuration) {
+ Map<String, Object> configuration) {
try {
int openParen = methodDesc.indexOf(Constants.LEFT_PARENTHESIS);
int closeParen = methodDesc.indexOf(Constants.RIGHT_PARENTHESIS);
String methodName = methodDesc.substring(0, openParen);
String[] arguments = methodDesc.substring(openParen + 1, closeParen).split(Constants.COMMA);
MethodConfiguration.setClz(configuration, className);
- MethodConfiguration.setMethod(configuration, CustomizeUtil.generateOperationName(className, methodName, arguments));
+ MethodConfiguration.setMethod(
+ configuration, CustomizeUtil.generateOperationName(className, methodName, arguments));
MethodConfiguration.setMethodName(configuration, methodName);
- MethodConfiguration.setArguments(configuration, StringUtil.isEmpty(arguments[0]) ? new String[0] : arguments);
+ MethodConfiguration.setArguments(
+ configuration, StringUtil.isEmpty(arguments[0]) ? new String[0] : arguments);
if (StringUtil.isEmpty(MethodConfiguration.getOperationName(configuration))) {
MethodConfiguration.setOperationName(configuration, MethodConfiguration.getMethod(configuration));
}
@@ -243,8 +250,10 @@ public enum CustomizeConfiguration {
* In order to avoid the judgment of the useless null pointer exception.
*/
private void init() {
- Config.Plugin.Customize.CONTEXT.put(Constants.CONTEXT_METHOD_CONFIGURATIONS, new HashMap<String, Map<String, Object>>());
- Config.Plugin.Customize.CONTEXT.put(Constants.CONTEXT_ENHANCE_CLASSES, new HashMap<String, ElementMatcher>());
+ ConfigService.Plugin.Customize.CONTEXT.put(
+ Constants.CONTEXT_METHOD_CONFIGURATIONS, new HashMap<String, Map<String, Object>>());
+ ConfigService.Plugin.Customize.CONTEXT.put(
+ Constants.CONTEXT_ENHANCE_CLASSES, new HashMap<String, ElementMatcher>());
}
/**
@@ -263,7 +272,8 @@ public enum CustomizeConfiguration {
*/
@SuppressWarnings("unchecked")
private Map<String, Map<String, Object>> getMethodConfigurations() {
- return (Map<String, Map<String, Object>>) Config.Plugin.Customize.CONTEXT.get(Constants.CONTEXT_METHOD_CONFIGURATIONS);
+ return (Map<String, Map<String, Object>>) ConfigService.Plugin.Customize.CONTEXT.get(
+ Constants.CONTEXT_METHOD_CONFIGURATIONS);
}
/**
@@ -272,11 +282,13 @@ public enum CustomizeConfiguration {
* @param configuration {@link MethodConfiguration}
*/
private void addContextEnhanceClass(Map<String, Object> configuration) {
- String key = CustomizeUtil.generateClassDesc(MethodConfiguration.getClz(configuration), MethodConfiguration.isStatic(configuration));
+ String key = CustomizeUtil.generateClassDesc(
+ MethodConfiguration.getClz(configuration), MethodConfiguration.isStatic(configuration));
HashMap<String, ElementMatcher> enhanceClasses = getEnhanceClasses();
ElementMatcher matcher = enhanceClasses.get(key);
- enhanceClasses.put(key, matcher == null ? parserMethodsMatcher(configuration) : ((ElementMatcher.Junction) matcher)
- .or(parserMethodsMatcher(configuration)));
+ enhanceClasses.put(
+ key, matcher == null ? parserMethodsMatcher(configuration) : ((ElementMatcher.Junction) matcher)
+ .or(parserMethodsMatcher(configuration)));
}
/**
@@ -287,11 +299,13 @@ public enum CustomizeConfiguration {
*/
private ElementMatcher parserMethodsMatcher(Map<String, Object> configuration) {
String[] arguments = MethodConfiguration.getArguments(configuration);
- ElementMatcher matcher = named(MethodConfiguration.getMethodName(configuration)).and(takesArguments(arguments.length));
+ ElementMatcher matcher = named(MethodConfiguration.getMethodName(configuration)).and(
+ takesArguments(arguments.length));
if (arguments.length > 0) {
for (int i = 0; i < arguments.length; i++) {
- matcher = ((ElementMatcher.Junction) matcher).and(CustomizeUtil.isJavaClass(arguments[i]) ? takesArgument(i, CustomizeUtil
- .getJavaClass(arguments[i])) : takesArgumentWithType(i, arguments[i]));
+ matcher = ((ElementMatcher.Junction) matcher).and(
+ CustomizeUtil.isJavaClass(arguments[i]) ? takesArgument(i, CustomizeUtil
+ .getJavaClass(arguments[i])) : takesArgumentWithType(i, arguments[i]));
}
}
return matcher;
@@ -327,7 +341,8 @@ public enum CustomizeConfiguration {
*/
@SuppressWarnings("unchecked")
private HashMap<String, ElementMatcher> getEnhanceClasses() {
- return (HashMap<String, ElementMatcher>) Config.Plugin.Customize.CONTEXT.get(Constants.CONTEXT_ENHANCE_CLASSES);
+ return (HashMap<String, ElementMatcher>) ConfigService.Plugin.Customize.CONTEXT.get(
+ Constants.CONTEXT_ENHANCE_CLASSES);
}
public Map<String, Object> getConfiguration(Method method) {
diff --git a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..a3dbd90
--- /dev/null
+++ b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.customize.conf.ConfigService
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/GetTransactionMethodInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/GetTransactionMethodInterceptor.java
index 6521d13..d72c54e 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/GetTransactionMethodInterceptor.java
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/GetTransactionMethodInterceptor.java
@@ -18,7 +18,7 @@
package org.apache.skywalking.apm.plugin.spring.transaction;
-import org.apache.skywalking.apm.agent.core.conf.Config;
+import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
@@ -28,41 +28,42 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.plugin.spring.transaction.context.Constants;
import org.springframework.transaction.TransactionDefinition;
-import java.lang.reflect.Method;
-
public class GetTransactionMethodInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
if (allArguments[0] == null) {
- AbstractSpan span = ContextManager.createLocalSpan(Constants.OPERATION_NAME_SPRING_TRANSACTION_NO_TRANSACTION_DEFINITION_GIVEN);
+ AbstractSpan span = ContextManager.createLocalSpan(
+ Constants.OPERATION_NAME_SPRING_TRANSACTION_NO_TRANSACTION_DEFINITION_GIVEN);
span.setComponent(ComponentsDefine.SPRING_TX);
return;
}
TransactionDefinition definition = (TransactionDefinition) allArguments[0];
- AbstractSpan span = ContextManager.createLocalSpan(Constants.OPERATION_NAME_SPRING_TRANSACTION_GET_TRANSACTION_METHOD + buildOperationName(definition
- .getName()));
+ AbstractSpan span = ContextManager.createLocalSpan(
+ Constants.OPERATION_NAME_SPRING_TRANSACTION_GET_TRANSACTION_METHOD + buildOperationName(definition
+ .getName()));
span.tag(Constants.TAG_SPRING_TRANSACTION_ISOLATION_LEVEL, String.valueOf(definition.getIsolationLevel()));
- span.tag(Constants.TAG_SPRING_TRANSACTION_PROPAGATION_BEHAVIOR, String.valueOf(definition.getPropagationBehavior()));
+ span.tag(
+ Constants.TAG_SPRING_TRANSACTION_PROPAGATION_BEHAVIOR, String.valueOf(definition.getPropagationBehavior()));
span.tag(Constants.TAG_SPRING_TRANSACTION_TIMEOUT, String.valueOf(definition.getTimeout()));
span.setComponent(ComponentsDefine.SPRING_TX);
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
ContextManager.stopSpan();
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class<?>[] argumentsTypes, Throwable t) {
+ Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
private String buildOperationName(String transactionDefinitionName) {
- if (!Config.Plugin.SpringTransaction.SIMPLIFY_TRANSACTION_DEFINITION_NAME) {
+ if (!SpringTXConfig.Plugin.SpringTransaction.SIMPLIFY_TRANSACTION_DEFINITION_NAME) {
return transactionDefinitionName;
}
String[] ss = transactionDefinitionName.split("\\.");
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/SpringTXConfig.java b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/SpringTXConfig.java
new file mode 100644
index 0000000..deded46
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/transaction/SpringTXConfig.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugin.spring.transaction;
+
+import org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService;
+
+public class SpringTXConfig implements ConfigInitializationService {
+ @Override
+ public Class config() {
+ return SpringTXConfig.class;
+ }
+
+ public static class Plugin {
+ public static class SpringTransaction {
+
+ /**
+ * If true, the transaction definition name will be simplified
+ */
+ public static boolean SIMPLIFY_TRANSACTION_DEFINITION_NAME = false;
+ }
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
new file mode 100644
index 0000000..ac38638
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/spring-tx-plugin/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.ConfigInitializationService
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+#
+
+org.apache.skywalking.apm.plugin.spring.transaction.SpringTXConfig
\ No newline at end of file