Search in sources :

Example 31 with DefaultProfilerConfig

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

the class TargetBeanFilterTest method target4.

@Test
public void target4() {
    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, "");
    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.*");
    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_NAME_PATTERN_POSTFIX, "Target.*");
    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));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Foo", 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 32 with DefaultProfilerConfig

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

the class SpringBeansConfigTest method pattern.

@Test
public void pattern() {
    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_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
    // normal
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    // old
    properties.put(SpringBeansConfig.SPRING_BEANS_NAME_PATTERN, "com.navercorp.*");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
    assertEquals(3, 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 33 with DefaultProfilerConfig

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

the class SpringBeansConfigTest method backwardCompatibility.

@Test
public void backwardCompatibility() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_NAME_PATTERN, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN, "com.navercorp.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_ANNOTATION, "org.springframework.stereotype.Controller, org.springframework.stereotype.Servicem, org.springframework.stereotype.Repository");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Repository");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
    // backward compatiblity.
    assertEquals(5, 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 34 with DefaultProfilerConfig

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

the class VertxHttpServerConfigTest method config.

@Test
public void config() {
    Properties properties = new Properties();
    properties.setProperty("profiler.vertx.http.server.tracerequestparam", "true");
    properties.setProperty("profiler.vertx.http.server.excludeurl", "/l7/check");
    properties.setProperty("profiler.vertx.http.server.realipheader", "RealIp");
    properties.setProperty("profiler.vertx.http.server.realipemptyvalue", "unknown");
    properties.setProperty("profiler.vertx.http.server.excludemethod", "chunk, continue");
    ProfilerConfig profilerConfig = new DefaultProfilerConfig(properties);
    VertxHttpServerConfig config = new VertxHttpServerConfig(profilerConfig);
    assertEquals(true, config.isTraceRequestParam());
    assertEquals(true, config.getExcludeUrlFilter().filter("/l7/check"));
    assertEquals("RealIp", config.getRealIpHeader());
    assertEquals("unknown", config.getRealIpEmptyValue());
    assertEquals(true, config.getExcludeProfileMethodFilter().filter("CHUNK"));
    properties = new Properties();
    properties.setProperty("profiler.vertx.http.server.tracerequestparam", "false");
    properties.setProperty("profiler.vertx.http.server.excludeurl", "");
    properties.setProperty("profiler.vertx.http.server.realipheader", "");
    properties.setProperty("profiler.vertx.http.server.realipemptyvalue", "");
    properties.setProperty("profiler.vertx.http.server.excludemethod", "");
    profilerConfig = new DefaultProfilerConfig(properties);
    config = new VertxHttpServerConfig(profilerConfig);
    assertEquals(false, config.isTraceRequestParam());
    assertEquals(false, config.getExcludeUrlFilter().filter("/l7/check"));
    assertEquals("", config.getRealIpHeader());
    assertEquals("", config.getRealIpEmptyValue());
    assertEquals(false, config.getExcludeProfileMethodFilter().filter("CHUNK"));
}
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 35 with DefaultProfilerConfig

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

the class MockApplicationContextModuleTest method testMockApplicationContext.

@Test
public void testMockApplicationContext() {
    ProfilerConfig profilerConfig = new DefaultProfilerConfig();
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
    DefaultApplicationContext applicationContext = new DefaultApplicationContext(agentOption, binder) {

        @Override
        protected Module newApplicationContextModule(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
            Module module = super.newApplicationContextModule(agentOption, interceptorRegistryBinder);
            PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
            return Modules.override(module).with(pluginApplicationContextModule);
        }
    };
    Injector injector = applicationContext.getInjector();
    // singleton check
    AgentInfoSender instance1 = injector.getInstance(AgentInfoSender.class);
    AgentInfoSender instance2 = injector.getInstance(AgentInfoSender.class);
    Assert.assertSame(instance1, instance2);
    ClassFileTransformerDispatcher instance4 = injector.getInstance(ClassFileTransformerDispatcher.class);
}
Also used : InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) AgentInfoSender(com.navercorp.pinpoint.profiler.AgentInfoSender) ClassFileTransformerDispatcher(com.navercorp.pinpoint.profiler.ClassFileTransformerDispatcher) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) Injector(com.google.inject.Injector) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) Module(com.google.inject.Module) Test(org.junit.Test)

Aggregations

DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)36 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)33 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 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 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)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 Slf4jLoggerBinder (com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder)2 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)2 MockApplicationContext (com.navercorp.pinpoint.test.MockApplicationContext)2 TestClassLoader (com.navercorp.pinpoint.test.classloader.TestClassLoader)2 Instrumentation (java.lang.instrument.Instrumentation)2