diff --git a/agent/src/main/resources/pinpoint.config b/agent/src/main/resources/pinpoint.config index 1232c4470d5d6..5d6f4dada3cc5 100644 --- a/agent/src/main/resources/pinpoint.config +++ b/agent/src/main/resources/pinpoint.config @@ -56,6 +56,10 @@ profiler.tcpdatasender.command.accept.enable=true #profiler.applicationservertype=TOMCAT #profiler.applicationservertype=BLOC +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= ########################################################### # user defined classes # @@ -216,4 +220,4 @@ profiler.log4j.logging.transactioninfo=false ########################################################### # logback ########################################################### -profiler.logback.logging.transactioninfo=false \ No newline at end of file +profiler.logback.logging.transactioninfo=false diff --git a/agent/src/test/resources/pinpoint-spring-bean-test.config b/agent/src/test/resources/pinpoint-spring-bean-test.config index 3c787b397280e..5f6a9def21e2d 100644 --- a/agent/src/test/resources/pinpoint-spring-bean-test.config +++ b/agent/src/test/resources/pinpoint-spring-bean-test.config @@ -56,6 +56,10 @@ profiler.tcpdatasender.command.accept.enable=true #profiler.applicationservertype=TOMCAT #profiler.applicationservertype=BLOC +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= ########################################################### # user defined classes # @@ -194,4 +198,4 @@ profiler.log4j.logging.transactioninfo=false ########################################################### # logback ########################################################### -profiler.logback.logging.transactioninfo=false \ No newline at end of file +profiler.logback.logging.transactioninfo=false diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java index bf63f93447c53..36dac5b80916b 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java @@ -18,11 +18,13 @@ import com.navercorp.pinpoint.bootstrap.util.NumberUtils; import com.navercorp.pinpoint.bootstrap.util.spring.PropertyPlaceholderHelper; -import com.navercorp.pinpoint.common.ServiceType; import com.navercorp.pinpoint.common.util.PropertyUtils; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -210,6 +212,7 @@ public static ProfilerConfig load(String pinpointConfigFileName) throws IOExcept private long agentInfoSendRetryInterval = DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL; private String applicationServerType; + private List applicationTypeDetectOrder = Collections.emptyList(); private boolean log4jLoggingTransactionInfo; private boolean logbackLoggingTransactionInfo; @@ -589,6 +592,10 @@ public boolean isRedisPipelineEnabled() { public Filter getProfilableClassFilter() { return profilableClassFilter; } + + public List getApplicationTypeDetectOrder() { + return applicationTypeDetectOrder; + } public String getApplicationServerType() { return applicationServerType; @@ -768,8 +775,10 @@ void readPropertyValues() { this.agentInfoSendRetryInterval = readLong("profiler.agentInfo.send.retry.interval", DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL); // service type - this.applicationServerType = readString("profiler.applicationservertype", ServiceType.STAND_ALONE.getName()); + this.applicationServerType = readString("profiler.applicationservertype", null); + // application type detector order + this.applicationTypeDetectOrder = readTypeDetectOrder("profiler.type.detect.order"); // TODO have to remove // profile package included in order to test "call stack view". @@ -836,6 +845,15 @@ public long readLong(String propertyName, long defaultValue) { return result; } + public List readTypeDetectOrder(String propertyName) { + String value = properties.getProperty(propertyName); + if (value == null) { + return Collections.emptyList(); + } + String[] orders = value.trim().split(","); + return Arrays.asList(orders); + } + public boolean readBoolean(String propertyName, boolean defaultValue) { String value = properties.getProperty(propertyName, Boolean.toString(defaultValue)); boolean result = Boolean.parseBoolean(value); @@ -845,7 +863,6 @@ public boolean readBoolean(String propertyName, boolean defaultValue) { return result; } - @Override public String toString() { final StringBuilder sb = new StringBuilder("ProfilerConfig{"); @@ -929,6 +946,7 @@ public String toString() { sb.append(", profilableClassFilter=").append(profilableClassFilter); sb.append(", DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL=").append(DEFAULT_AGENT_INFO_SEND_RETRY_INTERVAL); sb.append(", agentInfoSendRetryInterval=").append(agentInfoSendRetryInterval); + sb.append(", applicationTypeDetectOrder='").append(applicationTypeDetectOrder).append('\''); sb.append(", applicationServerType=").append(applicationServerType); sb.append('}'); return sb.toString(); diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/ServerTypeDetector.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/ServerTypeDetector.java index d517a0a6057f3..d53952107b6ba 100644 --- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/ServerTypeDetector.java +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/ServerTypeDetector.java @@ -14,13 +14,36 @@ */ package com.navercorp.pinpoint.bootstrap.plugin; +import com.navercorp.pinpoint.bootstrap.resolver.ConditionProvider; +import com.navercorp.pinpoint.common.ServiceType; /** * @author Jongho Moon + * @author HyunGil Jeong * */ public interface ServerTypeDetector { - public String getServerTypeName(); - public boolean detect(); - public boolean canOverride(String serverType); + + /** + * Returns the {@link ServiceType} representing the current plugin, + * with code in a range corresponding to {@link com.navercorp.pinpoint.common.ServiceTypeCategory#SERVER} + * + * @return the {@link ServiceType} representing the current plugin + * @see ServiceType#isWas() + * @see com.navercorp.pinpoint.common.ServiceTypeCategory#SERVER + */ + public ServiceType getServerType(); + + /** + * Checks whether the provided conditions satisfy the requirements given by the plugins implementing this class. + * + *

This method allows the agent to go through each of the registered plugins with classes implementing this interface, + * checking whether the execution environment satisfies the requirements specified in them, returning true if the + * requirements are satisfied. + * + * @param provider conditions provided by the current application + * @return true if the provided conditions satisfy the requirements, false if otherwise + * @see ConditionProvider + */ + public boolean detect(ConditionProvider provider); } diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ApplicationServerTypePluginResolver.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ApplicationServerTypePluginResolver.java new file mode 100644 index 0000000000000..78e51366fb8c8 --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ApplicationServerTypePluginResolver.java @@ -0,0 +1,72 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.navercorp.pinpoint.bootstrap.plugin.ServerTypeDetector; +import com.navercorp.pinpoint.common.ServiceType; + +/** + * This class attempts to resolve the current application type through {@link ServerTypeDetector}s. + * The application type is resolved by checking the conditions defined in each of the loaded detector's {@code detect} method. + *

+ * If no match is found, the application type defaults to {@code ServiceType.STAND_ALONE} + * + * @author HyunGil Jeong + */ +public class ApplicationServerTypePluginResolver { + + private final Logger logger = Logger.getLogger(ApplicationServerTypePluginResolver.class.getName()); + + private final List serverTypeDetectors; + + private final ConditionProvider conditionProvider; + + private static final ServiceType DEFAULT_SERVER_TYPE = ServiceType.STAND_ALONE; + + public ApplicationServerTypePluginResolver(List serverTypeDetectors) { + this(serverTypeDetectors, ConditionProvider.DEFAULT_CONDITION_PROVIDER); + } + + public ApplicationServerTypePluginResolver(List serverTypeDetectors, ConditionProvider conditionProvider) { + if (serverTypeDetectors == null) { + throw new IllegalArgumentException("serverTypeDetectors should not be null"); + } + if (conditionProvider == null) { + throw new IllegalArgumentException("conditionProvider should not be null"); + } + this.serverTypeDetectors = serverTypeDetectors; + this.conditionProvider = conditionProvider; + } + + public ServiceType resolve() { + for (ServerTypeDetector currentDetector : this.serverTypeDetectors) { + logger.log(Level.INFO, "Attempting to resolve using " + currentDetector.getClass()); + if (currentDetector.detect(this.conditionProvider)) { + logger.log(Level.INFO, "Match found using " + currentDetector.getClass().getSimpleName()); + return currentDetector.getServerType(); + } else { + logger.log(Level.INFO, "No match found using " + currentDetector.getClass()); + } + } + logger.log(Level.INFO, "Server type not resolved. Defaulting to " + DEFAULT_SERVER_TYPE.getName()); + return DEFAULT_SERVER_TYPE; + } +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ConditionProvider.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ConditionProvider.java new file mode 100644 index 0000000000000..050d72e1c7379 --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/ConditionProvider.java @@ -0,0 +1,84 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver; + +import java.util.HashMap; +import java.util.Map; + +import com.navercorp.pinpoint.bootstrap.resolver.condition.Condition; +import com.navercorp.pinpoint.bootstrap.resolver.condition.LibraryClassCondition; +import com.navercorp.pinpoint.bootstrap.resolver.condition.MainClassCondition; +import com.navercorp.pinpoint.bootstrap.resolver.condition.SystemPropertyCondition; + +/** + * @author HyunGil Jeong + */ +public class ConditionProvider { + + public static final ConditionProvider DEFAULT_CONDITION_PROVIDER = new ConditionProvider(); + + private final Map>, Condition> conditions; + + public ConditionProvider() { + this(new HashMap>, Condition>()); + } + + public ConditionProvider(Map>, Condition> conditions) { + this.conditions = conditions; + addDefaultConditions(); + } + + private void addDefaultConditions() { + this.conditions.put(MainClassCondition.class, new MainClassCondition()); + this.conditions.put(SystemPropertyCondition.class, new SystemPropertyCondition()); + this.conditions.put(LibraryClassCondition.class, new LibraryClassCondition()); + } + + public > T getCondition(Class conditionClass) { + @SuppressWarnings("unchecked") + T condition = (T)this.conditions.get(conditionClass); + return condition; + } + + /** + * Returns {@link MainClassCondition} that allows plugins to check for the application's bootstrap main class. + * + * @return the {@link MainClassCondition} + */ + public MainClassCondition getMainClassCondition() { + return (MainClassCondition)this.conditions.get(MainClassCondition.class); + } + + /** + * Returns {@link SystemPropertyCondition} that allows plugins to check for system property keys. + * + * @return the {@link SystemPropertyCondition} + */ + public SystemPropertyCondition getSystemPropertyCondition() { + return (SystemPropertyCondition)this.conditions.get(SystemPropertyCondition.class); + } + + /** + * Returns {@link LibraryClassCondition} that allows plugins to check for classes accessible by + * the system class loader. + * + * @return the {@link LibraryClassCondition} + */ + public LibraryClassCondition getLibraryClassCondition() { + return (LibraryClassCondition)this.conditions.get(LibraryClassCondition.class); + } +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/Condition.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/Condition.java new file mode 100644 index 0000000000000..1c3f0f3acd6f2 --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/Condition.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +/** + * @author HyunGil Jeong + */ +public interface Condition { + + public boolean matches(T condition); + +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/ConditionValue.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/ConditionValue.java new file mode 100644 index 0000000000000..d05d274bb7fab --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/ConditionValue.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +/** + * @author HyunGil Jeong + */ +public interface ConditionValue { + + public V getValue(); + +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/LibraryClassCondition.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/LibraryClassCondition.java new file mode 100644 index 0000000000000..a40b67c82d333 --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/LibraryClassCondition.java @@ -0,0 +1,54 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +/** + * Checks whether the specified classes are currently accessible by the System ClassLoader. + * + * @author HyunGil Jeong + */ +public class LibraryClassCondition implements Condition { + + private static final String CLASS_EXTENSION = ".class"; + + private String getClassNameAsResource(String className) { + String classNameAsResource = className.replace('.', '/'); + return classNameAsResource.endsWith(CLASS_EXTENSION) ? classNameAsResource : classNameAsResource.concat(CLASS_EXTENSION); + } + + /** + * Checks if the specified classes can be found in the current System ClassLoader's search path. + * + * @param requiredClasses the fully qualified class names of the classes to check + * @return true if all of the specified classes can be found in the system class loader's search path, + * false if otherwise + */ + @Override + public boolean matches(String ... requiredClasses) { + if (requiredClasses == null) { + return false; + } + for (String condition : requiredClasses) { + String classNameAsResource = getClassNameAsResource(condition); + if (ClassLoader.getSystemResource(classNameAsResource) == null) { + return false; + } + } + return true; + } + +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassCondition.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassCondition.java new file mode 100644 index 0000000000000..31e7b1edda1ad --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassCondition.java @@ -0,0 +1,107 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +import java.util.jar.JarFile; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.navercorp.pinpoint.common.util.SimpleProperty; +import com.navercorp.pinpoint.common.util.SystemProperty; +import com.navercorp.pinpoint.common.util.SystemPropertyKey; + +/** + * Checks if the application's main class is in one of those specified in {@link MainClassCondition}. + *

+ * The application's main class is extracted by reading the sun.java.command system property, and in cases + * of executable jars, the Main-Class attribute inside the manifest file. + * + * @author HyunGil Jeong + */ +public class MainClassCondition implements Condition, ConditionValue { + + private final Logger logger = Logger.getLogger(MainClassCondition.class.getName()); + + private static final String MANIFEST_MAIN_CLASS_KEY = "Main-Class"; + private static final String NOT_FOUND = null; + + private final String applicationMainClassName; + + public MainClassCondition() { + this(SystemProperty.INSTANCE); + } + + MainClassCondition(SimpleProperty property) { + if (property == null) { + throw new IllegalArgumentException("properties should not be null"); + } + this.applicationMainClassName = getMainClassName(property); + } + + /** + * Checks if the specified value matches the fully qualified class name of the application's main class. + * If the main class cannot be resolved, the method return false. + * + * @param condition the value to check against the application's main class name + * @return true if the specified value matches the name of the main class; + * false if otherwise, or if the main class cannot be resolved + */ + @Override + public boolean matches(String condition) { + if (this.applicationMainClassName == NOT_FOUND) { + return false; + } else { + return this.applicationMainClassName.equals(condition); + } + } + + /** + * Returns the fully qualified class name of the application's main class. + * + * @return the fully qualified class name of the main class, or an empty string if the main class cannot be resolved + */ + @Override + public String getValue() { + if (this.applicationMainClassName == NOT_FOUND) { + return ""; + } + return this.applicationMainClassName; + } + + private String getMainClassName(SimpleProperty property) { + String javaCommand = property.getProperty(SystemPropertyKey.SUN_JAVA_COMMAND.getKey(), "").split(" ")[0]; + if (javaCommand.isEmpty()) { + logger.log(Level.WARNING, "Error retrieving main class from " + property.getClass().getName()); + return NOT_FOUND; + } else if (javaCommand.endsWith(".jar")) { + return extractMainClassFromJar(javaCommand); + } else { + return javaCommand; + } + } + + private String extractMainClassFromJar(String jarName) { + try { + JarFile bootstrapJar = new JarFile(jarName); + return bootstrapJar.getManifest().getMainAttributes().getValue(MANIFEST_MAIN_CLASS_KEY); + } catch (Throwable t) { + logger.log(Level.WARNING, "Error retrieving main class from jar file : " + jarName, t); + return NOT_FOUND; + } + } + +} diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyCondition.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyCondition.java new file mode 100644 index 0000000000000..2f1f0dc74e81e --- /dev/null +++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyCondition.java @@ -0,0 +1,68 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +import com.navercorp.pinpoint.common.util.SystemProperty; + +/** + * Checks if the specified property keys are in the system property. + * + * @author HyunGil Jeong + */ +public class SystemPropertyCondition implements Condition, ConditionValue { + + private final SystemProperty property; + + public SystemPropertyCondition() { + this(SystemProperty.INSTANCE); + } + + SystemPropertyCondition(SystemProperty property) { + this.property = property; + } + + /** + * Checks if the specified values are in the system property. + * + * @param requiredKeys the values to check if they exist in the system property + * @return true if all of the specified keys are in the system property; + * false if otherwise, or if null values are provided + */ + @Override + public boolean matches(String ... requiredKeys) { + if (requiredKeys == null) { + return false; + } + for (String requiredKey : requiredKeys) { + if (this.property.getProperty(requiredKey) == null) { + return false; + } + } + return true; + } + + /** + * Returns the system property. + * + * @return the {@link SystemProperty} instance + */ + @Override + public SystemProperty getValue() { + return this.property; + } + +} diff --git a/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassConditionTest.java b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassConditionTest.java new file mode 100644 index 0000000000000..b8c7feadd516c --- /dev/null +++ b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/MainClassConditionTest.java @@ -0,0 +1,147 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import com.navercorp.pinpoint.bootstrap.resolver.condition.MainClassCondition; +import com.navercorp.pinpoint.common.util.SimpleProperty; +import com.navercorp.pinpoint.common.util.SystemPropertyKey; + +/** + * @author HyunGil Jeong + */ +public class MainClassConditionTest { + + private static final String TEST_MAIN_CLASS = "main.class.for.Test"; + + @Test + public void getValueShouldReturnBootstrapMainClass() { + // Given + SimpleProperty property = createTestProperty(TEST_MAIN_CLASS); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + String expectedMainClass = mainClassCondition.getValue(); + // Then + assertEquals(TEST_MAIN_CLASS, expectedMainClass); + } + + @Test + public void getValueShouldReturnEmptyStringWhenMainClassCannotBeResolved() { + // Given + SimpleProperty property = createTestProperty(); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + String expectedMainClass = mainClassCondition.getValue(); + // Then + assertEquals("", expectedMainClass); + } + + @Test + public void testMatch() { + // Given + SimpleProperty property = createTestProperty(TEST_MAIN_CLASS); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + boolean matches = mainClassCondition.matches(TEST_MAIN_CLASS); + // Then + assertTrue(matches); + } + + @Test + public void testNoMatch() { + // Given + String givenBootstrapMainClass = "some.other.main.class"; + SimpleProperty property = createTestProperty(givenBootstrapMainClass); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + boolean matches = mainClassCondition.matches(TEST_MAIN_CLASS); + // Then + assertFalse(matches); + } + + @Test + public void nullConditionShouldNotMatch() { + // Given + SimpleProperty property = createTestProperty(TEST_MAIN_CLASS); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + boolean matches = mainClassCondition.matches(null); + // Then + assertFalse(matches); + } + + @Test + public void shouldNotMatchWhenMainClassCannotBeResolved() { + // Given + SimpleProperty property = createTestProperty(); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + boolean matches = mainClassCondition.matches(null); + // Then + assertFalse(matches); + } + + @Test + public void shouldNotMatchWhenWhenJarFileCannotBeFound() { + // Given + SimpleProperty property = createTestProperty("non-existent-test-jar.jar"); + MainClassCondition mainClassCondition = new MainClassCondition(property); + // When + boolean matches = mainClassCondition.matches(null); + // Then + assertFalse(matches); + } + + private static SimpleProperty createTestProperty() { + return new SimpleProperty() { + + private final Map properties = new HashMap(); + + @Override + public void setProperty(String key, String value) { + this.properties.put(key, value); + } + + @Override + public String getProperty(String key) { + return this.properties.get(key); + } + + @Override + public String getProperty(String key, String defaultValue) { + if (this.properties.containsKey(key)) { + return this.properties.get(key); + } else { + return defaultValue; + } + } + }; + } + + private static SimpleProperty createTestProperty(String testMainClass) { + SimpleProperty testProperty = createTestProperty(); + testProperty.setProperty(SystemPropertyKey.SUN_JAVA_COMMAND.getKey(), testMainClass); + return testProperty; + } + +} diff --git a/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyConditionTest.java b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyConditionTest.java new file mode 100644 index 0000000000000..8c05eae764cc6 --- /dev/null +++ b/bootstrap/src/test/java/com/navercorp/pinpoint/bootstrap/resolver/condition/SystemPropertyConditionTest.java @@ -0,0 +1,146 @@ +/* + * Copyright 2015 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.bootstrap.resolver.condition; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import com.navercorp.pinpoint.bootstrap.resolver.condition.SystemPropertyCondition; +import com.navercorp.pinpoint.common.util.SystemProperty; + +/** + * @author HyunGil Jeong + */ +public class SystemPropertyConditionTest { + + @Test + public void testMatch() { + // Given + final String existingSystemProperty1 = "set.one.key.one"; + final String existingSystemProperty2 = "set.one.key.two"; + SystemProperty property = createTestProperty(existingSystemProperty1, existingSystemProperty2); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + // When + boolean matches = systemPropertyCondition.matches(existingSystemProperty1, existingSystemProperty2); + // Then + assertTrue(matches); + } + + @Test + public void testNoMatch() { + // Given + final String existingSystemProperty = "existing.system.property"; + SystemProperty property = createTestProperty(existingSystemProperty); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + // When + boolean matches = systemPropertyCondition.matches("some.other.property"); + // Then + assertFalse(matches); + } + + @Test + public void partialMatchShouldResultInNoMatch() { + // Given + final String existingSystemProperty = "set.one.key.one"; + SystemProperty property = createTestProperty(existingSystemProperty); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + // When + boolean matches = systemPropertyCondition.matches(existingSystemProperty, "some.other.property"); + // Then + assertFalse(matches); + } + + @Test + public void emptyConditionShouldMatch() { + // Given + final String existingSystemProperty = "existing.system.property"; + SystemProperty property = createTestProperty(existingSystemProperty); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + // When + boolean matches = systemPropertyCondition.matches(new String[0]); + // Then + assertTrue(matches); + } + + @Test + public void conditionWithNullElementShouldMatch() { + // Given + final String existingSystemProperty = "existing.system.property"; + SystemProperty property = createTestProperty(existingSystemProperty); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + final String[] conditionWithNullElement = new String[] {null}; + // When + boolean matches = systemPropertyCondition.matches(conditionWithNullElement); + // Then + assertFalse(matches); + } + + @Test + public void nullConditionShouldNotMatch() { + // Given + final String existingSystemProperty = "existing.system.property"; + SystemProperty property = createTestProperty(existingSystemProperty); + SystemPropertyCondition systemPropertyCondition = new SystemPropertyCondition(property); + final String[] nullCondition = null; + // When + boolean matches = systemPropertyCondition.matches(nullCondition); + // Then + assertFalse(matches); + } + + private static SystemProperty createTestProperty() { + return new SystemProperty() { + + private final Map properties = new HashMap(); + + @Override + public void setProperty(String key, String value) { + this.properties.put(key, value); + } + + @Override + public String getProperty(String key) { + return this.properties.get(key); + } + + @Override + public String getProperty(String key, String defaultValue) { + if (this.properties.containsKey(key)) { + return this.properties.get(key); + } else { + return defaultValue; + } + } + }; + } + + private static SystemProperty createTestProperty(String ... keys) { + SystemProperty property = createTestProperty(); + if (keys == null) { + return property; + } + for (String key : keys) { + property.setProperty(key, ""); + } + return property; + } + +} diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/SystemPropertyKey.java b/commons/src/main/java/com/navercorp/pinpoint/common/util/SystemPropertyKey.java index 785b3ca843b37..aab8eac87ce90 100644 --- a/commons/src/main/java/com/navercorp/pinpoint/common/util/SystemPropertyKey.java +++ b/commons/src/main/java/com/navercorp/pinpoint/common/util/SystemPropertyKey.java @@ -29,7 +29,8 @@ public enum SystemPropertyKey { JAVA_VM_NAME("java.vm.name"), JAVA_VM_VERSION("java.vm.version"), JAVA_VM_INFO("java.vm.info"), - JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"); + JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"), + SUN_JAVA_COMMAND("sun.java.command"); // May be unsupported depending on the JVM. private final String key; diff --git a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/TomcatDetector.java b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/TomcatDetector.java index 9ff260ccb7042..6704aacd5b8c7 100644 --- a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/TomcatDetector.java +++ b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/TomcatDetector.java @@ -14,47 +14,34 @@ */ package com.navercorp.pinpoint.plugin.tomcat; -import java.io.File; - -import com.navercorp.pinpoint.bootstrap.logging.PLogger; -import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; import com.navercorp.pinpoint.bootstrap.plugin.ServerTypeDetector; -import com.navercorp.pinpoint.common.util.SystemProperty; +import com.navercorp.pinpoint.bootstrap.resolver.ConditionProvider; +import com.navercorp.pinpoint.common.ServiceType; /** * @author Jongho Moon + * @author HyunGil Jeong * */ public class TomcatDetector implements ServerTypeDetector, TomcatConstants { - private final PLogger logger = PLoggerFactory.getLogger(getClass()); + + private static final String REQUIRED_MAIN_CLASS = "org.apache.catalina.startup.Bootstrap"; + + private static final String REQUIRED_SYSTEM_PROPERTY = "catalina.home"; + + private static final String REQUIRED_CLASS = "org.apache.catalina.startup.Bootstrap"; @Override - public String getServerTypeName() { - return TYPE_NAME; - } - - public boolean detect() { - String homeDir = SystemProperty.INSTANCE.getProperty("catalina.home"); - - if (homeDir == null) { - logger.debug("catalina.home is not defined. This is not a Tomcat instance"); - return false; - } - - File catalinaJar = new File(homeDir, "/lib/catalina.jar"); - - if (!catalinaJar.exists()) { - logger.debug(catalinaJar + " is not exist. This is not a Tomcat instance"); - return false; - } - - logger.debug("catalina.home (" + homeDir + ") is defined and " + catalinaJar + " is exist. This is a Tomcat instance"); - - return catalinaJar.exists(); + public ServiceType getServerType() { + return TOMCAT; } @Override - public boolean canOverride(String serverType) { - return false; + public boolean detect(ConditionProvider provider) { + String bootstrapMain = provider.getMainClassCondition().getValue(); + return bootstrapMain.equals(REQUIRED_MAIN_CLASS) && + provider.getSystemPropertyCondition().matches(REQUIRED_SYSTEM_PROPERTY) && + provider.getLibraryClassCondition().matches(REQUIRED_CLASS); } + } diff --git a/plugins/tomcat/src/test/resources/pinpoint.config b/plugins/tomcat/src/test/resources/pinpoint.config index d8d1493febe49..4fa92abdb5fdb 100644 --- a/plugins/tomcat/src/test/resources/pinpoint.config +++ b/plugins/tomcat/src/test/resources/pinpoint.config @@ -55,6 +55,10 @@ profiler.tcpdatasender.command.accept.enable=true #profiler.applicationservertype=TOMCAT #profiler.applicationservertype=BLOC +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= ########################################################### # user defined classes # diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java index 635297157d459..74c47a57dd2c3 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/DefaultAgent.java @@ -43,7 +43,6 @@ import com.navercorp.pinpoint.common.plugin.PluginLoader; import com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; -import com.navercorp.pinpoint.exception.PinpointException; import com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataHolder; import com.navercorp.pinpoint.profiler.context.DefaultTraceContext; import com.navercorp.pinpoint.profiler.context.storage.BufferedStorageFactory; @@ -170,15 +169,12 @@ public DefaultAgent(String agentArgs, Instrumentation instrumentation, ProfilerC String applicationServerTypeString = profilerConfig.getApplicationServerType(); ServiceType applicationServerType = this.serviceTypeRegistryService.findServiceTypeByName(applicationServerTypeString); - final ApplicationServerTypeResolver typeResolver = new ApplicationServerTypeResolver(pluginContexts, applicationServerType, this.serviceTypeRegistryService); - if (!typeResolver.resolve()) { - throw new PinpointException("ApplicationServerType not found."); - } + final ApplicationServerTypeResolver typeResolver = new ApplicationServerTypeResolver(pluginContexts, applicationServerType, profilerConfig.getApplicationTypeDetectOrder()); final AgentInformationFactory agentInformationFactory = new AgentInformationFactory(); - this.agentInformation = agentInformationFactory.createAgentInformation(typeResolver.getServerType()); + this.agentInformation = agentInformationFactory.createAgentInformation(typeResolver.resolve()); logger.info("agentInformation:{}", agentInformation); - + CommandDispatcher commandDispatcher = createCommandDispatcher(); this.tcpDataSender = createTcpDataSender(commandDispatcher); diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/ApplicationServerTypeResolver.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/ApplicationServerTypeResolver.java index 6230c47635c31..40e51081d7f0e 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/ApplicationServerTypeResolver.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/util/ApplicationServerTypeResolver.java @@ -17,85 +17,62 @@ package com.navercorp.pinpoint.profiler.util; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.navercorp.pinpoint.bootstrap.plugin.ServerTypeDetector; +import com.navercorp.pinpoint.bootstrap.resolver.ApplicationServerTypePluginResolver; import com.navercorp.pinpoint.common.ServiceType; -import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; import com.navercorp.pinpoint.profiler.plugin.DefaultProfilerPluginContext; /** * @author emeroad * @author netspider + * @author hyungil.jeong */ public class ApplicationServerTypeResolver { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private ServiceType serverType; - private final ServiceType defaultType; + private final ApplicationServerTypePluginResolver resolver; private final List detectors = new ArrayList(); - private final ServiceTypeRegistryService serviceTypeRegistryService; - - public ApplicationServerTypeResolver(List plugins, ServiceType defaultType, ServiceTypeRegistryService serviceTypeRegistryService) { - if (serviceTypeRegistryService == null) { - throw new NullPointerException("serviceTypeRegistryService must not be null"); - } - this.serviceTypeRegistryService = serviceTypeRegistryService; + public ApplicationServerTypeResolver(List plugins, ServiceType defaultType, List orderedDetectors) { this.defaultType = defaultType; - - for (DefaultProfilerPluginContext context : plugins) { - detectors.addAll(context.getServerTypeDetectors()); + Map registeredDetectors = getRegisteredServerTypeDetectors(plugins); + for (String orderedDetector : orderedDetectors) { + if (registeredDetectors.containsKey(orderedDetector)); + this.detectors.add(registeredDetectors.remove(orderedDetector)); } - } - - public String[] getServerLibPath() { - return new String[0]; - } - - public ServiceType getServerType() { - return serverType; + this.detectors.addAll(registeredDetectors.values()); + this.resolver = new ApplicationServerTypePluginResolver(this.detectors); } - public boolean resolve() { - String serverType = null; - - for (ServerTypeDetector detector : detectors) { - logger.debug("try to resolve using {}", detector.getClass()); - - if (serverType != null && !detector.canOverride(serverType)) { - continue; - } - - if (detector.detect()) { - serverType = detector.getServerTypeName(); - - if (logger.isInfoEnabled()) { - logger.info("Resolved applicationServerType [{}] by {}", serverType, detector.getClass().getName()); - } + private Map getRegisteredServerTypeDetectors(List plugins) { + Map registeredDetectors = new HashMap(); + for (DefaultProfilerPluginContext context : plugins) { + for (ServerTypeDetector detector : context.getServerTypeDetectors()) { + registeredDetectors.put(detector.getClass().getName(), detector); } } - - if (serverType != null) { - this.serverType = serviceTypeRegistryService.findServiceTypeByName(serverType); - return true; - } - - if (defaultType != null) { - // TODO validate default type. is defaultType a server type? - this.serverType = defaultType; + return registeredDetectors; + } + + public ServiceType resolve() { + ServiceType resolvedApplicationServerType; + if (this.defaultType == ServiceType.UNDEFINED) { + resolvedApplicationServerType = this.resolver.resolve(); + logger.info("Resolved ApplicationServerType : {}", resolvedApplicationServerType.getName()); } else { - this.serverType = ServiceType.STAND_ALONE; - } - - if (logger.isInfoEnabled()) { - logger.info("Configured applicationServerType:{}", defaultType); + // TODO Should we check if defaultType is a valid server type? + resolvedApplicationServerType = this.defaultType; + logger.info("Configured ApplicationServerType : {}", resolvedApplicationServerType.getName()); } - - return true; + return resolvedApplicationServerType; } } diff --git a/profiler/src/test/resources/pinpoint-spring-bean-test.config b/profiler/src/test/resources/pinpoint-spring-bean-test.config index 3c787b397280e..5a376f9a4975a 100644 --- a/profiler/src/test/resources/pinpoint-spring-bean-test.config +++ b/profiler/src/test/resources/pinpoint-spring-bean-test.config @@ -1,197 +1,201 @@ -# -# Pinpoint agent configuration -# - -########################################################### -# Collector server # -########################################################### -profiler.collector.ip=127.0.0.1 - -# placeHolder support "${key}" -profiler.collector.span.ip=${profiler.collector.ip} -profiler.collector.span.port=9996 - -# placeHolder support "${key}" -profiler.collector.stat.ip=${profiler.collector.ip} -profiler.collector.stat.port=9995 - -# placeHolder support "${key}" -profiler.collector.tcp.ip=${profiler.collector.ip} -profiler.collector.tcp.port=9994 - - -########################################################### -# Profiler Global Configuration # -########################################################### -profiler.enable=true - -profiler.jvm.collect.interval=1000 - -profiler.sampling.enable=true - -# Set sampling rate. If you set it to 10, 1 out of 10 transaction will be sampled. -profiler.sampling.rate=1 - -profiler.io.buffering.enable=true -profiler.io.buffering.buffersize=20 - -profiler.spandatasender.write.queue.size=5120 -#profiler.spandatasender.socket.sendbuffersize=1048576 -#profiler.spandatasender.socket.timeout=3000 -profiler.spandatasender.chunk.size=16384 - -profiler.statdatasender.write.queue.size=5120 -#profiler.statdatasender.socket.sendbuffersize=1048576 -#profiler.statdatasender.socket.timeout=3000 -profiler.statdatasender.chunk.size=16384 - -profiler.agentInfo.send.retry.interval=300000 - -# Allows TCP data command -profiler.tcpdatasender.command.accept.enable=true - -########################################################### -# application type # -########################################################### -#profiler.applicationservertype=TOMCAT -#profiler.applicationservertype=BLOC - - -########################################################### -# user defined classes # -########################################################### -profiler.include= - -########################################################### -# TOMCAT # -########################################################### -profiler.tomcat.hidepinpointheader=true -profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html - -########################################################### -# JDBC # -########################################################### -profiler.jdbc=true -profiler.jdbc.sqlcachesize=1024 -profiler.jdbc.maxsqlbindvaluesize=1024 - -# -# MYSQL -# -profiler.jdbc.mysql=true -profiler.jdbc.mysql.setautocommit=true -profiler.jdbc.mysql.commit=true -profiler.jdbc.mysql.rollback=true - -# -# MSSQL Jtds -# -profiler.jdbc.jtds=true -profiler.jdbc.jtds.setautocommit=true -profiler.jdbc.jtds.commit=true -profiler.jdbc.jtds.rollback=true - -# -# Oracle -# -profiler.jdbc.oracle=true -profiler.jdbc.oracle.setautocommit=true -profiler.jdbc.oracle.commit=true -profiler.jdbc.oracle.rollback=true - -# -# CUBRID -# -profiler.jdbc.cubrid=true -profiler.jdbc.cubrid.setautocommit=true -profiler.jdbc.cubrid.commit=true -profiler.jdbc.cubrid.rollback=true - -# -# DBCP -# -profiler.jdbc.dbcp=true -profiler.jdbc.dbcp.connectionclose=true - - -########################################################### -# Apache HTTP Client 4.x # -########################################################### -profiler.apache.httpclient4=true -profiler.apache.httpclient4.cookie=true - -# When cookies should be dumped. It could be ALWAYS or EXCEPTION. -profiler.apache.httpclient4.cookie.dumptype=ALWAYS -profiler.apache.httpclient4.cookie.sampling.rate=1 - -# Dump entities of POST or PUT request. limited to entities which is HttpEtity.isRepeatable() == true. -profiler.apache.httpclient4.entity=true - -# When entities should be dumped. ALWAYS or EXCEPTION. -profiler.apache.httpclient4.entity.dumptype=ALWAYS -profiler.apache.httpclient4.entity.sampling.rate=1 - -profiler.apache.nio.httpclient4=true - - -########################################################### -# Ning Async HTTP Client # -########################################################### -profiler.ning.asynchttpclient=true -profiler.ning.asynchttpclient.cookie=true -profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS -profiler.ning.asynchttpclient.cookie.dumpsize=1024 -profiler.ning.asynchttpclient.cookie.sampling.rate=1 -profiler.ning.asynchttpclient.entity=true -profiler.ning.asynchttpclient.entity.dumptype=ALWAYS -profiler.ning.asynchttpclient.entity.dumpsize=1024 -profiler.ning.asynchttpclient.entity.sampling.rate=1 -profiler.ning.asynchttpclient.param=true -profiler.ning.asynchttpclient.param.dumptype=ALWAYS -profiler.ning.asynchttpclient.param.dumpsize=1024 -profiler.ning.asynchttpclient.param.sampling.rate=1 - - -########################################################### -# Arcus # -########################################################### -profiler.arcus=true -profiler.arcus.keytrace=true - - -########################################################### -# Memcached # -########################################################### -profiler.memcached=true -profiler.memcached.keytrace=true - - -########################################################### -# ibatis # -########################################################### -profiler.orm.ibatis=true - - -########################################################### -# mybatis # -########################################################### -profiler.orm.mybatis=true - - -########################################################### -# spring-beans -########################################################### -profiler.spring.beans=true -profiler.spring.beans.name.pattern=ma.*, outer -profiler.spring.beans.class.pattern=.*Morae -profiler.spring.beans.annotation=org.springframework.stereotype.Component - -########################################################### -# log4j -########################################################### -profiler.log4j.logging.transactioninfo=false - -########################################################### -# logback -########################################################### -profiler.logback.logging.transactioninfo=false \ No newline at end of file +# +# Pinpoint agent configuration +# + +########################################################### +# Collector server # +########################################################### +profiler.collector.ip=127.0.0.1 + +# placeHolder support "${key}" +profiler.collector.span.ip=${profiler.collector.ip} +profiler.collector.span.port=9996 + +# placeHolder support "${key}" +profiler.collector.stat.ip=${profiler.collector.ip} +profiler.collector.stat.port=9995 + +# placeHolder support "${key}" +profiler.collector.tcp.ip=${profiler.collector.ip} +profiler.collector.tcp.port=9994 + + +########################################################### +# Profiler Global Configuration # +########################################################### +profiler.enable=true + +profiler.jvm.collect.interval=1000 + +profiler.sampling.enable=true + +# Set sampling rate. If you set it to 10, 1 out of 10 transaction will be sampled. +profiler.sampling.rate=1 + +profiler.io.buffering.enable=true +profiler.io.buffering.buffersize=20 + +profiler.spandatasender.write.queue.size=5120 +#profiler.spandatasender.socket.sendbuffersize=1048576 +#profiler.spandatasender.socket.timeout=3000 +profiler.spandatasender.chunk.size=16384 + +profiler.statdatasender.write.queue.size=5120 +#profiler.statdatasender.socket.sendbuffersize=1048576 +#profiler.statdatasender.socket.timeout=3000 +profiler.statdatasender.chunk.size=16384 + +profiler.agentInfo.send.retry.interval=300000 + +# Allows TCP data command +profiler.tcpdatasender.command.accept.enable=true + +########################################################### +# application type # +########################################################### +#profiler.applicationservertype=TOMCAT +#profiler.applicationservertype=BLOC + +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= + +########################################################### +# user defined classes # +########################################################### +profiler.include= + +########################################################### +# TOMCAT # +########################################################### +profiler.tomcat.hidepinpointheader=true +profiler.tomcat.excludeurl=/aa/test.html, /bb/exclude.html + +########################################################### +# JDBC # +########################################################### +profiler.jdbc=true +profiler.jdbc.sqlcachesize=1024 +profiler.jdbc.maxsqlbindvaluesize=1024 + +# +# MYSQL +# +profiler.jdbc.mysql=true +profiler.jdbc.mysql.setautocommit=true +profiler.jdbc.mysql.commit=true +profiler.jdbc.mysql.rollback=true + +# +# MSSQL Jtds +# +profiler.jdbc.jtds=true +profiler.jdbc.jtds.setautocommit=true +profiler.jdbc.jtds.commit=true +profiler.jdbc.jtds.rollback=true + +# +# Oracle +# +profiler.jdbc.oracle=true +profiler.jdbc.oracle.setautocommit=true +profiler.jdbc.oracle.commit=true +profiler.jdbc.oracle.rollback=true + +# +# CUBRID +# +profiler.jdbc.cubrid=true +profiler.jdbc.cubrid.setautocommit=true +profiler.jdbc.cubrid.commit=true +profiler.jdbc.cubrid.rollback=true + +# +# DBCP +# +profiler.jdbc.dbcp=true +profiler.jdbc.dbcp.connectionclose=true + + +########################################################### +# Apache HTTP Client 4.x # +########################################################### +profiler.apache.httpclient4=true +profiler.apache.httpclient4.cookie=true + +# When cookies should be dumped. It could be ALWAYS or EXCEPTION. +profiler.apache.httpclient4.cookie.dumptype=ALWAYS +profiler.apache.httpclient4.cookie.sampling.rate=1 + +# Dump entities of POST or PUT request. limited to entities which is HttpEtity.isRepeatable() == true. +profiler.apache.httpclient4.entity=true + +# When entities should be dumped. ALWAYS or EXCEPTION. +profiler.apache.httpclient4.entity.dumptype=ALWAYS +profiler.apache.httpclient4.entity.sampling.rate=1 + +profiler.apache.nio.httpclient4=true + + +########################################################### +# Ning Async HTTP Client # +########################################################### +profiler.ning.asynchttpclient=true +profiler.ning.asynchttpclient.cookie=true +profiler.ning.asynchttpclient.cookie.dumptype=ALWAYS +profiler.ning.asynchttpclient.cookie.dumpsize=1024 +profiler.ning.asynchttpclient.cookie.sampling.rate=1 +profiler.ning.asynchttpclient.entity=true +profiler.ning.asynchttpclient.entity.dumptype=ALWAYS +profiler.ning.asynchttpclient.entity.dumpsize=1024 +profiler.ning.asynchttpclient.entity.sampling.rate=1 +profiler.ning.asynchttpclient.param=true +profiler.ning.asynchttpclient.param.dumptype=ALWAYS +profiler.ning.asynchttpclient.param.dumpsize=1024 +profiler.ning.asynchttpclient.param.sampling.rate=1 + + +########################################################### +# Arcus # +########################################################### +profiler.arcus=true +profiler.arcus.keytrace=true + + +########################################################### +# Memcached # +########################################################### +profiler.memcached=true +profiler.memcached.keytrace=true + + +########################################################### +# ibatis # +########################################################### +profiler.orm.ibatis=true + + +########################################################### +# mybatis # +########################################################### +profiler.orm.mybatis=true + + +########################################################### +# spring-beans +########################################################### +profiler.spring.beans=true +profiler.spring.beans.name.pattern=ma.*, outer +profiler.spring.beans.class.pattern=.*Morae +profiler.spring.beans.annotation=org.springframework.stereotype.Component + +########################################################### +# log4j +########################################################### +profiler.log4j.logging.transactioninfo=false + +########################################################### +# logback +########################################################### +profiler.logback.logging.transactioninfo=false diff --git a/profiler/src/test/resources/pinpoint.config b/profiler/src/test/resources/pinpoint.config index 407712f5ef04c..7494b10d859c0 100644 --- a/profiler/src/test/resources/pinpoint.config +++ b/profiler/src/test/resources/pinpoint.config @@ -55,6 +55,10 @@ profiler.tcpdatasender.command.accept.enable=true #profiler.applicationservertype=TOMCAT #profiler.applicationservertype=BLOC +########################################################### +# application type detect order # +########################################################### +profiler.type.detect.order= ########################################################### # user defined classes # @@ -206,4 +210,4 @@ profiler.log4j.logging.transactioninfo=false ########################################################### # logback ########################################################### -profiler.logback.logging.transactioninfo=false \ No newline at end of file +profiler.logback.logging.transactioninfo=false