Search in sources :

Example 26 with ProfilerConfig

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

the class SpringBeansConfigTest method invalid.

@Test
public void invalid() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + "foo", "Target.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + "bar", "org.springframework.stereotype.Controller");
    // empty
    properties.put("foo" + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put("bar" + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    // wrong number 1.
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6.12 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6.12 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    // wrong number 2.
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + "A" + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + "A" + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    // not found number
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
    assertEquals(0, springBeansConfig.getTargets().size());
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) Properties(java.util.Properties) Test(org.junit.Test)

Example 27 with ProfilerConfig

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

the class TargetBeanFilterTest method assertClassNamePattern.

private void assertClassNamePattern(final String pattern) {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, pattern);
    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)

Example 28 with ProfilerConfig

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

the class TargetBeanFilterTest method beansNamePattern.

@Test
public void beansNamePattern() {
    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_NAME_PATTERN_POSTFIX, "A.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "B.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "C.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 5 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "antstyle:D*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "antstyle:E?");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 7 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "antstyle:F.A*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 8 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "antstyle:.G*");
    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));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "AAA", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "BBB", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "CCC", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "DDD", beanDefinition));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "EEE", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "EE", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "F.AA", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, ".GG", beanDefinition));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "GG", beanDefinition));
    filter.addTransformed(String.class.getName());
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target1", 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 29 with ProfilerConfig

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

the class TargetBeanFilterTest method annotation.

@Test
public void annotation() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + 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));
}
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 30 with ProfilerConfig

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

the class TargetBeanFilterTest method target1.

@Test
public void target1() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + 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));
}
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)

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