Search in sources :

Example 36 with ProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig 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)

Example 37 with ProfilerConfig

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

the class DefaultTraceContextTest method transactionCountTest.

@Test
public void transactionCountTest() {
    final int samplingRate = 5;
    final ProfilerConfig profilerConfig = Mockito.mock(ProfilerConfig.class);
    Mockito.when(profilerConfig.isTraceAgentActiveThread()).thenReturn(true);
    Mockito.when((profilerConfig.getSamplingRate())).thenReturn(samplingRate);
    Mockito.when((profilerConfig.isSamplingEnable())).thenReturn(true);
    MockTraceContextFactory mockTraceContextFactory = MockTraceContextFactory.newTestTraceContextFactory(profilerConfig);
    final TraceContext traceContext = mockTraceContextFactory.getTraceContext();
    final TransactionCounter transactionCounter = new DefaultTransactionCounter(mockTraceContextFactory.getIdGenerator());
    final long newTransactionCount = 22L;
    @SuppressWarnings("unused") final long expectedSampledNewCount = newTransactionCount / samplingRate + (newTransactionCount % samplingRate > 0 ? 1 : 0);
    final long expectedUnsampledNewCount = newTransactionCount - expectedSampledNewCount;
    for (int i = 0; i < newTransactionCount; ++i) {
        traceContext.newTraceObject();
        traceContext.removeTraceObject();
    }
    final long expectedSampledContinuationCount = 5L;
    for (int i = 0; i < expectedSampledContinuationCount; ++i) {
        traceContext.continueTraceObject(new DefaultTraceId("agentId", 0L, i));
        traceContext.removeTraceObject();
    }
    final long expectedUnsampledContinuationCount = 10L;
    for (int i = 0; i < expectedUnsampledContinuationCount; ++i) {
        traceContext.disableSampling();
        traceContext.removeTraceObject();
    }
    final long expectedTotalTransactionCount = expectedSampledNewCount + expectedUnsampledNewCount + expectedSampledContinuationCount + expectedUnsampledContinuationCount;
    Assert.assertEquals(expectedSampledNewCount, transactionCounter.getSampledNewCount());
    Assert.assertEquals(expectedUnsampledNewCount, transactionCounter.getUnSampledNewCount());
    Assert.assertEquals(expectedSampledContinuationCount, transactionCounter.getSampledContinuationCount());
    Assert.assertEquals(expectedUnsampledContinuationCount, transactionCounter.getUnSampledContinuationCount());
    Assert.assertEquals(expectedTotalTransactionCount, transactionCounter.getTotalTransactionCount());
}
Also used : DefaultTransactionCounter(com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext) DefaultTransactionCounter(com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter) TransactionCounter(com.navercorp.pinpoint.profiler.context.id.TransactionCounter) Test(org.junit.Test)

Example 38 with ProfilerConfig

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

the class DependencyGraph method newApplicationContext.

private DefaultApplicationContext newApplicationContext() {
    ProfilerConfig profilerConfig = new DefaultProfilerConfig();
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    Instrumentation instrumentation = mock(Instrumentation.class);
    AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
    return new DefaultApplicationContext(agentOption, binder);
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) 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) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) Instrumentation(java.lang.instrument.Instrumentation) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)

Example 39 with ProfilerConfig

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

the class NetworkAvailabilityChecker method main.

public static void main(String[] args) {
    if (args.length != 1) {
        System.out.println("usage : " + NetworkAvailabilityChecker.class.getSimpleName() + " AGENT_CONFIG_FILE");
        return;
    }
    String configPath = args[0];
    ProfilerConfig profilerConfig = null;
    try {
        profilerConfig = DefaultProfilerConfig.load(configPath);
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    try {
        checkUDPStat(profilerConfig);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        checkUDPSpan(profilerConfig);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        checkTCP(profilerConfig);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) IOException(java.io.IOException) TException(org.apache.thrift.TException) IOException(java.io.IOException)

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