Search in sources :

Example 1 with DefaultAgentOption

use of com.navercorp.pinpoint.bootstrap.DefaultAgentOption in project pinpoint by naver.

the class MockApplicationContextModuleTest method test.

@Test
public void test() {
    ProfilerConfig profilerConfig = spy(new DefaultProfilerConfig());
    when(profilerConfig.getStaticResourceCleanup()).thenReturn(true);
    URL resource = getClass().getResource("/");
    when(profilerConfig.readString(Profiles.LOG_CONFIG_LOCATION_KEY, null)).thenReturn(resource.getPath());
    Instrumentation instrumentation = Mockito.mock(Instrumentation.class);
    AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgentId", "mockAgentName", "mockApplicationName", false, profilerConfig, Collections.<String>emptyList(), Collections.<String>emptyList());
    PluginTestAgent pluginTestAgent = new PluginTestAgent(agentOption);
    try {
        pluginTestAgent.start();
    } finally {
        pluginTestAgent.stop();
    }
}
Also used : DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) Instrumentation(java.lang.instrument.Instrumentation) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) URL(java.net.URL) Test(org.junit.Test)

Example 2 with DefaultAgentOption

use of com.navercorp.pinpoint.bootstrap.DefaultAgentOption in project pinpoint by naver.

the class DefaultApplicationContextTest method newApplicationContext.

private DefaultApplicationContext newApplicationContext() {
    ProfilerConfig profilerConfig = spy(new DefaultProfilerConfig());
    when(profilerConfig.getStaticResourceCleanup()).thenReturn(true);
    // when(profilerConfig.getTransportModule()).thenReturn("GRPC");
    Instrumentation instrumentation = mock(Instrumentation.class);
    AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgentId", "mockAgentName", "mockApplicationName", false, profilerConfig, Collections.<String>emptyList(), Collections.<String>emptyList());
    InterceptorRegistryBinder interceptorRegistryBinder = new TestInterceptorRegistryBinder();
    Module interceptorRegistryModule = InterceptorRegistryModule.wrap(interceptorRegistryBinder);
    ModuleFactory moduleFactory = new OverrideModuleFactory(interceptorRegistryModule);
    return new DefaultApplicationContext(agentOption, moduleFactory);
}
Also used : DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) 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) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) Instrumentation(java.lang.instrument.Instrumentation) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) Module(com.google.inject.Module)

Example 3 with DefaultAgentOption

use of com.navercorp.pinpoint.bootstrap.DefaultAgentOption in project pinpoint by naver.

the class MockApplicationContext method of.

public static MockApplicationContext of(ProfilerConfig config) {
    AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", config, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    binder.bind();
    return new MockApplicationContext(agentOption, binder);
}
Also used : DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)

Example 4 with DefaultAgentOption

use of com.navercorp.pinpoint.bootstrap.DefaultAgentOption in project pinpoint by naver.

the class MockApplicationContextFactory method build.

public DefaultApplicationContext build(ProfilerConfig config, ModuleFactory moduleFactory) {
    Instrumentation instrumentation = new DummyInstrumentation();
    String mockAgentId = "mockAgentId";
    String mockAgentName = "mockAgentName";
    String mockApplicationName = "mockApplicationName";
    AgentOption agentOption = new DefaultAgentOption(instrumentation, mockAgentId, mockAgentName, mockApplicationName, false, config, Collections.<String>emptyList(), Collections.<String>emptyList());
    return new DefaultApplicationContext(agentOption, moduleFactory);
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) Instrumentation(java.lang.instrument.Instrumentation) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption)

Example 5 with DefaultAgentOption

use of com.navercorp.pinpoint.bootstrap.DefaultAgentOption in project pinpoint by naver.

the class MockApplicationContextModuleTest method testMockApplicationContext.

@Test
public void testMockApplicationContext() {
    ProfilerConfig profilerConfig = spy(new DefaultProfilerConfig());
    when(profilerConfig.getStaticResourceCleanup()).thenReturn(true);
    Instrumentation instrumentation = Mockito.mock(Instrumentation.class);
    AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgentId", "mockAgentName", "mockApplicationName", false, profilerConfig, Collections.<String>emptyList(), Collections.<String>emptyList());
    Module pluginModule = new PluginApplicationContextModule();
    InterceptorRegistryBinder interceptorRegistryBinder = new TestInterceptorRegistryBinder();
    Module testInterceptorRegistryModule = InterceptorRegistryModule.wrap(interceptorRegistryBinder);
    ModuleFactory moduleFactory = new OverrideModuleFactory(pluginModule, testInterceptorRegistryModule);
    DefaultApplicationContext applicationContext = new DefaultApplicationContext(agentOption, moduleFactory);
    Injector injector = applicationContext.getInjector();
    // singleton check
    AgentInfoSender instance1 = injector.getInstance(AgentInfoSender.class);
    AgentInfoSender instance2 = injector.getInstance(AgentInfoSender.class);
    Assert.assertSame(instance1, instance2);
    ClassFileTransformer instance4 = injector.getInstance(ClassFileTransformer.class);
    applicationContext.close();
}
Also used : ClassFileTransformer(java.lang.instrument.ClassFileTransformer) 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) Instrumentation(java.lang.instrument.Instrumentation) AgentInfoSender(com.navercorp.pinpoint.profiler.AgentInfoSender) ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) Injector(com.google.inject.Injector) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) Module(com.google.inject.Module) Test(org.junit.Test)

Aggregations

AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)7 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)7 Instrumentation (java.lang.instrument.Instrumentation)6 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)4 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)4 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)4 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)4 Module (com.google.inject.Module)3 ModuleFactory (com.navercorp.pinpoint.profiler.context.module.ModuleFactory)2 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)2 Test (org.junit.Test)2 Injector (com.google.inject.Injector)1 GraphvizModule (com.google.inject.grapher.graphviz.GraphvizModule)1 DefaultAnnotationKeyRegistryService (com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)1 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)1 AgentInfoSender (com.navercorp.pinpoint.profiler.AgentInfoSender)1 InterceptorRegistryModule (com.navercorp.pinpoint.profiler.context.module.InterceptorRegistryModule)1 OverrideModuleFactory (com.navercorp.pinpoint.profiler.context.module.OverrideModuleFactory)1 ClassFileTransformer (java.lang.instrument.ClassFileTransformer)1 URL (java.net.URL)1