use of com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter in project pinpoint by naver.
the class ActiveTraceRepositoryTest method setUp.
@Before
public void setUp() {
final ProfilerConfig profilerConfig = Mockito.mock(ProfilerConfig.class);
Mockito.when(profilerConfig.isTraceAgentActiveThread()).thenReturn(true);
Mockito.when(profilerConfig.isSamplingEnable()).thenReturn(true);
Mockito.when(profilerConfig.getSamplingRate()).thenReturn(SAMPLING_RATE);
MockTraceContextFactory mockTraceContextFactory = MockTraceContextFactory.newTestTraceContextFactory(profilerConfig);
this.traceContext = mockTraceContextFactory.getTraceContext();
this.transactionCounter = new DefaultTransactionCounter(mockTraceContextFactory.getIdGenerator());
this.activeTraceRepository = mockTraceContextFactory.getActiveTraceRepository();
}
use of com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter 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.profiler.context.id.DefaultTransactionCounter in project pinpoint by naver.
the class DefaultTransactionCounterTest method setUp.
@Before
public void setUp() throws Exception {
this.idGenerator = new AtomicIdGenerator();
this.transactionCounter = new DefaultTransactionCounter(this.idGenerator);
}
Aggregations