Separate config initialization in the plugin out of core level Config. (#5136)

This commit is contained in:
吴晟 Wu Sheng 2020-07-21 20:51:56 +08:00 committed by GitHub
parent cff36b63bc
commit 20b1b51798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 905 additions and 455 deletions

View File

@ -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.agent.core.boot;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 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.
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface PluginConfig {
/**
* @return Class as the root to do config initialization.
*/
Class<?> root();
}

View File

@ -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 {

View File

@ -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 {

View File

@ -34,6 +34,8 @@ import java.util.jar.JarFile;
import lombok.RequiredArgsConstructor;
import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer;
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.PluginBootstrap;
@ -99,14 +101,15 @@ public class AgentClassLoader extends ClassLoader {
try {
URL classFileUrl = new URL("jar:file:" + jar.sourceFile.getAbsolutePath() + "!/" + path);
byte[] data;
try (final BufferedInputStream is = new BufferedInputStream(classFileUrl.openStream()); final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try (final BufferedInputStream is = new BufferedInputStream(
classFileUrl.openStream()); final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
int ch;
while ((ch = is.read()) != -1) {
baos.write(ch);
}
data = baos.toByteArray();
}
return defineClass(name, data, 0, data.length);
return processLoadedClass(defineClass(name, data, 0, data.length));
} catch (IOException e) {
logger.error(e, "find class fail.");
}
@ -154,6 +157,18 @@ public class AgentClassLoader extends ClassLoader {
};
}
private Class<?> processLoadedClass(Class<?> loadedClass) {
final PluginConfig pluginConfig = loadedClass.getAnnotation(PluginConfig.class);
if (pluginConfig != null) {
// Set up the plugin config when loaded by class loader at the first time.
// Agent class loader just loaded limited classes in the plugin jar(s), so the cost of this
// isAssignableFrom would be also very limited.
SnifferConfigInitializer.initializeConfig(pluginConfig.root());
}
return loadedClass;
}
private List<Jar> getAllJars() {
if (allJars == null) {
jarScanLock.lock();

View File

@ -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"));
}

View File

@ -61,10 +61,9 @@ 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());
} catch (AgentPackageNotFoundException ape) {
logger.error(ape, "Locate agent.jar failure. Shutting down.");
return;

View File

@ -0,0 +1,35 @@
/*
* 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.PluginConfig;
public class ElasticsearchPluginConfig {
public static class Plugin {
@PluginConfig(root = ElasticsearchPluginConfig.class)
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;
}
}
}

View File

@ -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.ElasticsearchPluginConfig.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;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
public class TransportProxyClientInterceptor implements InstanceConstructorInterceptor {

View File

@ -0,0 +1,35 @@
/*
* 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.PluginConfig;
public class ElasticsearchPluginConfig {
public static class Plugin {
@PluginConfig(root = ElasticsearchPluginConfig.class)
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;
}
}
}

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.ELASTICSEARCH_DSL_LENGTH_THRESHOLD;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
public class AdapterActionFutureActionGetMethodsInterceptor implements InstanceMethodsAroundInterceptor {

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor.Constants.DB_TYPE;
import java.lang.reflect.Method;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
public class TransportActionNodeProxyExecuteMethodsInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor {

View File

@ -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.ElasticsearchPluginConfig.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;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.Plugin.Elasticsearch.TRACE_DSL;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.when;

View File

@ -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.ElasticsearchPluginConfig.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);

View File

@ -0,0 +1,33 @@
/*
* 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.PluginConfig;
public class InfluxDBPluginConfig {
public static class Plugin {
@PluginConfig(root = InfluxDBPluginConfig.class)
public static class InfluxDB {
/**
* If set to true, the parameters of the InfluxQL would be collected.
*/
public static boolean TRACE_INFLUXQL = true;
}
}
}

View File

@ -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.InfluxDBPluginConfig;
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 || !InfluxDBPluginConfig.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);
}
}

View File

@ -0,0 +1,74 @@
/*
* 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.PluginConfig;
public class JDBCPluginConfig {
public static class Plugin {
@PluginConfig(root = JDBCPluginConfig.class)
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;
}
@PluginConfig(root = JDBCPluginConfig.class)
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;
}
}
}

View File

@ -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 (JDBCPluginConfig.Plugin.MySQL.TRACE_SQL_PARAMETERS || JDBCPluginConfig.Plugin.POSTGRESQL.TRACE_SQL_PARAMETERS || JDBCPluginConfig.Plugin.MARIADB.TRACE_SQL_PARAMETERS) {
final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS;
for (String setter : setters) {
matcher = matcher.or(named(setter));

View File

@ -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 Light4JPluginConfig.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 (Light4JPluginConfig.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 (Light4JPluginConfig.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 (Light4JPluginConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN && !exchange.isInIoThread()) {
ContextManager.stopSpan();
}
} else if (Config.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(objInst) || isBusinessHandler(objInst))) {
} else if (Light4JPluginConfig.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) {

View File

@ -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.plugin.light4j;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class Light4JPluginConfig {
public static class Plugin {
@PluginConfig(root = Light4JPluginConfig.class)
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;
}
}
}

View File

@ -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.JDBCPluginConfig;
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 (JDBCPluginConfig.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(JDBCPluginConfig.Plugin.MARIADB.SQL_PARAMETERS_MAX_LENGTH)
.build();
}
}

View File

@ -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.JDBCPluginConfig;
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;
JDBCPluginConfig.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);
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);
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);

View File

@ -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

View File

@ -0,0 +1,42 @@
/*
* 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.PluginConfig;
public class MongoPluginConfig {
public static class Plugin {
@PluginConfig(root = MongoPluginConfig.class)
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;
}
}
}

View File

@ -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.MongoPluginConfig;
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 = MongoPluginConfig.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 = MongoPluginConfig.Plugin.MongoDB.FILTER_LENGTH_LIMIT;
if (filterLengthLimit > 0 && filter.length() > filterLengthLimit) {
return params.append(filter, 0, filterLengthLimit).append("...").toString();
} else {

View File

@ -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.MongoPluginConfig;
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 (MongoPluginConfig.Plugin.MongoDB.TRACE_PARAM) {
Tags.DB_STATEMENT.set(span, executeMethod + " " + MongoOperationHelper.getTraceParam(operation));
}
}

View File

@ -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.MongoPluginConfig;
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;
MongoPluginConfig.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));

View File

@ -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.MongoPluginConfig;
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;
MongoPluginConfig.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));

View File

@ -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.JDBCPluginConfig;
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 (JDBCPluginConfig.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(JDBCPluginConfig.Plugin.MySQL.SQL_PARAMETERS_MAX_LENGTH)
.build();
}
}

View File

@ -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.JDBCPluginConfig;
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 (JDBCPluginConfig.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(JDBCPluginConfig.Plugin.POSTGRESQL.SQL_PARAMETERS_MAX_LENGTH)
.build();
}
}

View File

@ -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 (SolrJPluginConfig.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 (SolrJPluginConfig.Plugin.SolrJ.TRACE_STATEMENT) {
span.tag(SolrjTags.TAG_DOCS_SIZE, String.valueOf(documents.size()));
}
}
if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
if (SolrJPluginConfig.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 (SolrJPluginConfig.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 (SolrJPluginConfig.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;

View File

@ -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.solrj;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class SolrJPluginConfig {
public static class Plugin {
@PluginConfig(root = SolrJPluginConfig.class)
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;
}
}
}

View File

@ -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 (SolrJPluginConfig.Plugin.SolrJ.TRACE_STATEMENT) {
SpanAssert.assertTag(span, ++pox, "100");
}
if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
if (SolrJPluginConfig.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 (SolrJPluginConfig.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 (SolrJPluginConfig.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 (SolrJPluginConfig.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 (SolrJPluginConfig.Plugin.SolrJ.TRACE_STATEMENT) {
SpanAssert.assertTag(span, ++start, statement);
}
if (Config.Plugin.SolrJ.TRACE_OPS_PARAMS) {
if (SolrJPluginConfig.Plugin.SolrJ.TRACE_OPS_PARAMS) {
SpanAssert.assertTag(span, ++start, "-1");
}

View File

@ -0,0 +1,50 @@
/*
* 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.PluginConfig;
public class SpringMVCPluginConfig {
public static class Plugin {
@PluginConfig(root = SpringMVCPluginConfig.class)
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;
}
@PluginConfig(root = SpringMVCPluginConfig.class)
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;
}
}
}

View File

@ -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.SpringMVCPluginConfig;
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 (SpringMVCPluginConfig.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 (SpringMVCPluginConfig.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 (!SpringMVCPluginConfig.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 = SpringMVCPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ?
StringUtil.cut(tagValue, SpringMVCPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) : tagValue;
Tags.HTTP.PARAMS.set(span, tagValue);
}
}

View File

@ -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 (TomcatPluginConfig.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 (!TomcatPluginConfig.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 = TomcatPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ?
StringUtil.cut(tagValue, TomcatPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) :
tagValue;
Tags.HTTP.PARAMS.set(span, tagValue);
}
}

View File

@ -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.tomcat78x;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class TomcatPluginConfig {
public static class Plugin {
@PluginConfig(root = TomcatPluginConfig.class)
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;
}
@PluginConfig(root = TomcatPluginConfig.class)
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;
}
}
}

View File

@ -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.toolkit.activation;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class ToolkitPluginConfig {
public static class Plugin {
@PluginConfig(root = ToolkitPluginConfig.class)
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;
}
}
}

View File

@ -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.ToolkitPluginConfig;
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 || ToolkitPluginConfig.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);
}
}

View File

@ -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.plugin.jdk.threading;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class JDKThreadingPluginConfig {
public static class Plugin {
@PluginConfig(root = JDKThreadingPluginConfig.class)
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 = "";
}
}
}

View File

@ -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 = JDKThreadingPluginConfig.Plugin.JdkThreading.THREADING_CLASS_PREFIXES;
if (jointPrefixes == null || jointPrefixes.trim().isEmpty()) {
return null;

View File

@ -26,11 +26,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@ -60,13 +60,41 @@ public enum CustomizeConfiguration {
private static final ILog logger = LogManager.getLogger(CustomizeConfiguration.class);
/**
* The load method is resolver configuration file, and parse it to kernel.
* Some information after custom enhancements, this configuration is used by the custom enhancement plugin.
* And using Map CONTEXT for avoiding classloader isolation issue.
*/
public void load() {
private static final Map<String, Map<String, Object>> CONTEXT_METHOD_CONFIGURATIONS = new HashMap<>();
private static final Map<String, ElementMatcher> CONTEXT_ENHANCE_CLASSES = new HashMap<>();
private static final AtomicBoolean LOAD_FOR_CONFIGURATION = new AtomicBoolean(false);
/**
* The loadForEnhance method is resolver configuration file, and parse it
*/
public void loadForEnhance() {
try {
parse(resolver());
for (Map<String, Object> configuration : resolver()) {
addContextEnhanceClass(configuration);
}
} catch (Exception e) {
logger.error("CustomizeConfiguration load fail", e);
logger.error("CustomizeConfiguration loadForAgent fail", e);
}
}
/**
* The loadForConfiguration method is resolver configuration file, and parse it
*/
public synchronized void loadForConfiguration() {
if (LOAD_FOR_CONFIGURATION.get()) {
return;
}
try {
for (Map<String, Object> configuration : resolver()) {
addContextMethodConfiguration(configuration);
}
} catch (Exception e) {
logger.error("CustomizeConfiguration loadForConfiguration fail", e);
} finally {
LOAD_FOR_CONFIGURATION.set(true);
}
}
@ -80,7 +108,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(CustomizePluginConfig.Plugin.Customize.ENHANCE_FILE);
if (file.exists() && file.isFile()) {
NodeList classNodeList = resolverFileClassDesc(file);
resolverClassNodeList(classNodeList, customizeMethods);
@ -118,8 +146,8 @@ public enum CustomizeConfiguration {
Node methodDesc = methodNodeList.item(ms);
if (methodDesc.getNodeType() == Node.ELEMENT_NODE) {
String className = classDesc.getAttributes()
.getNamedItem(Constants.XML_ELEMENT_CLASS_NAME)
.getNodeValue();
.getNamedItem(Constants.XML_ELEMENT_CLASS_NAME)
.getNodeValue();
Map<String, Object> configuration = resolverMethodNodeDesc(className, methodDesc);
if (configuration != null) {
customizeMethods.add(configuration);
@ -140,32 +168,36 @@ 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)
.getNodeValue());
.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)
.getNodeValue()));
.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)
.getNodeValue()));
.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)
.getNodeValue()));
.getNamedItem(
Constants.XML_ELEMENT_METHOD_IS_STATIC)
.getNodeValue()));
}
setAdvancedField(configuration, methodDesc);
return resolverClassAndMethod(className, methodDesc.getAttributes()
.getNamedItem(Constants.XML_ELEMENT_METHOD)
.getNodeValue(), configuration);
.getNamedItem(Constants.XML_ELEMENT_METHOD)
.getNodeValue(), configuration);
}
/**
@ -183,14 +215,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 +240,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));
}
@ -226,27 +262,6 @@ public enum CustomizeConfiguration {
return null;
}
/**
* Put the plugin configuration into the kernel according to the configuration.
*
* @param configurations is a bridge resolver method and parse method, mainly used for decoupling.
*/
private void parse(List<Map<String, Object>> configurations) {
init();
for (Map<String, Object> configuration : configurations) {
addContextMethodConfiguration(configuration);
addContextEnhanceClass(configuration);
}
}
/**
* 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>());
}
/**
* The configuration of each method is put into the kernel.
*
@ -263,7 +278,7 @@ 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 CONTEXT_METHOD_CONFIGURATIONS;
}
/**
@ -272,11 +287,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 +304,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,10 +346,13 @@ 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>) CONTEXT_ENHANCE_CLASSES;
}
public Map<String, Object> getConfiguration(Method method) {
if (!LOAD_FOR_CONFIGURATION.get()) {
loadForConfiguration();
}
return getMethodConfigurations().get(MethodUtil.generateOperationName(method));
}
}

View File

@ -0,0 +1,33 @@
/*
* 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 org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class CustomizePluginConfig {
public static class Plugin {
@PluginConfig(root = CustomizePluginConfig.class)
public static class Customize {
/**
* Custom enhancement class configuration file path, recommended to use an absolute path.
*/
public static String ENHANCE_FILE = "";
}
}
}

View File

@ -43,7 +43,7 @@ public class CustomizeInstrumentationLoader implements InstrumentationLoader {
@Override
public List<AbstractClassEnhancePluginDefine> load(AgentClassLoader classLoader) {
List<AbstractClassEnhancePluginDefine> instrumentations = new ArrayList<AbstractClassEnhancePluginDefine>();
CustomizeConfiguration.INSTANCE.load();
CustomizeConfiguration.INSTANCE.loadForEnhance();
Set<String> enhanceClasses = CustomizeConfiguration.INSTANCE.getInstrumentations();
try {
for (String enhanceClass : enhanceClasses) {

View File

@ -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 (!SpringTXPluginConfig.Plugin.SpringTransaction.SIMPLIFY_TRANSACTION_DEFINITION_NAME) {
return transactionDefinitionName;
}
String[] ss = transactionDefinitionName.split("\\.");

View File

@ -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.plugin.spring.transaction;
import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
public class SpringTXPluginConfig {
public static class Plugin {
@PluginConfig(root = SpringTXPluginConfig.class)
public static class SpringTransaction {
/**
* If true, the transaction definition name will be simplified
*/
public static boolean SIMPLIFY_TRANSACTION_DEFINITION_NAME = false;
}
}
}