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);
}
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());
}
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);
}
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();
}
}
Aggregations