Search in sources :

Example 1 with DefaultTransactionCounter

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();
}
Also used : DefaultTransactionCounter(com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter) MockTraceContextFactory(com.navercorp.pinpoint.profiler.context.MockTraceContextFactory) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) Before(org.junit.Before)

Example 2 with DefaultTransactionCounter

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());
}
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 3 with DefaultTransactionCounter

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);
}
Also used : DefaultTransactionCounter(com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter) AtomicIdGenerator(com.navercorp.pinpoint.profiler.context.id.AtomicIdGenerator) Before(org.junit.Before)

Aggregations

DefaultTransactionCounter (com.navercorp.pinpoint.profiler.context.id.DefaultTransactionCounter)3 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)2 Before (org.junit.Before)2 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)1 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)1 MockTraceContextFactory (com.navercorp.pinpoint.profiler.context.MockTraceContextFactory)1 AtomicIdGenerator (com.navercorp.pinpoint.profiler.context.id.AtomicIdGenerator)1 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)1 TransactionCounter (com.navercorp.pinpoint.profiler.context.id.TransactionCounter)1 Test (org.junit.Test)1