Search in sources :

Example 21 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.

the class TargetBeanFilterTest method target3.

@Test
public void target3() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 22 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.

the class TargetBeanFilterTest method target2.

@Test
public void target2() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 23 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.

the class TargetBeanFilterTest method target5.

@Test
public void target5() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target1, Target2");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target0");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target1", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target2", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 24 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.

the class TargetBeanFilterTest method empty.

@Test
public void empty() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    filter.addTransformed(String.class.getName());
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 25 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.

the class PinpointStarter method start.

boolean start() {
    final IdValidator idValidator = new IdValidator();
    final String agentId = idValidator.getAgentId();
    if (agentId == null) {
        return false;
    }
    final String applicationName = idValidator.getApplicationName();
    if (applicationName == null) {
        return false;
    }
    URL[] pluginJars = classPathResolver.resolvePlugins();
    // TODO using PLogger instead of CommonLogger
    CommonLoggerFactory loggerFactory = StdoutCommonLoggerFactory.INSTANCE;
    TraceMetadataLoaderService typeLoaderService = new DefaultTraceMetadataLoaderService(pluginJars, loggerFactory);
    ServiceTypeRegistryService serviceTypeRegistryService = new DefaultServiceTypeRegistryService(typeLoaderService, loggerFactory);
    AnnotationKeyRegistryService annotationKeyRegistryService = new DefaultAnnotationKeyRegistryService(typeLoaderService, loggerFactory);
    String configPath = getConfigPath(classPathResolver);
    if (configPath == null) {
        return false;
    }
    // set the path of log file as a system property
    saveLogFilePath(classPathResolver);
    savePinpointVersion();
    try {
        // Is it right to load the configuration in the bootstrap?
        ProfilerConfig profilerConfig = DefaultProfilerConfig.load(configPath);
        // this is the library list that must be loaded
        List<URL> libUrlList = resolveLib(classPathResolver);
        AgentClassLoader agentClassLoader = new AgentClassLoader(libUrlList.toArray(new URL[libUrlList.size()]));
        final String bootClass = getBootClass();
        agentClassLoader.setBootClass(bootClass);
        logger.info("pinpoint agent [" + bootClass + "] starting...");
        AgentOption option = createAgentOption(agentId, applicationName, profilerConfig, instrumentation, pluginJars, bootstrapJarFile, serviceTypeRegistryService, annotationKeyRegistryService);
        Agent pinpointAgent = agentClassLoader.boot(option);
        pinpointAgent.start();
        registerShutdownHook(pinpointAgent);
        logger.info("pinpoint agent started normally.");
    } catch (Exception e) {
        // unexpected exception that did not be checked above
        logger.warn(ProductInfo.NAME + " start failed.", e);
        return false;
    }
    return true;
}
Also used : TraceMetadataLoaderService(com.navercorp.pinpoint.common.service.TraceMetadataLoaderService) DefaultTraceMetadataLoaderService(com.navercorp.pinpoint.common.service.DefaultTraceMetadataLoaderService) AnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.AnnotationKeyRegistryService) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) ServiceTypeRegistryService(com.navercorp.pinpoint.common.service.ServiceTypeRegistryService) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) URL(java.net.URL) DefaultTraceMetadataLoaderService(com.navercorp.pinpoint.common.service.DefaultTraceMetadataLoaderService) CommonLoggerFactory(com.navercorp.pinpoint.common.util.logger.CommonLoggerFactory) StdoutCommonLoggerFactory(com.navercorp.pinpoint.common.util.logger.StdoutCommonLoggerFactory) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)

Aggregations

ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)39 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)36 Test (org.junit.Test)25 Properties (java.util.Properties)24 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)12 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)12 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)5 DefaultAnnotationKeyRegistryService (com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)5 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)5 AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)4 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)4 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)4 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)3 Module (com.google.inject.Module)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)2 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)2 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)2 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)2 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)2