Search in sources :

Example 1 with DefaultTraceId

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceId in project pinpoint by naver.

the class SpanStreamSendDataPlanerTest method createSpan.

private Span createSpan(List<SpanEvent> spanEventList) {
    DefaultTraceId traceId = new DefaultTraceId("test", 0, 1);
    Span span = new Span();
    for (SpanEvent spanEvent : spanEventList) {
        span.addToSpanEventList(spanEvent);
    }
    span.setAgentId("agentId");
    span.recordTraceId(traceId);
    return span;
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 2 with DefaultTraceId

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceId in project pinpoint by naver.

the class TraceTest method trace.

@Test
public void trace() {
    TraceId traceId = new DefaultTraceId("agent", 0, 1);
    CallStackFactory callStackFactory = new DefaultCallStackFactory(64);
    SpanFactory spanFactory = new DefaultSpanFactory("appName", "agentId", 0, ServiceType.STAND_ALONE);
    StringMetaDataService stringMetaDataService = mock(StringMetaDataService.class);
    SqlMetaDataService sqlMetaDataService = mock(SqlMetaDataService.class);
    RecorderFactory recorderFactory = new DefaultRecorderFactory(stringMetaDataService, sqlMetaDataService);
    AsyncIdGenerator asyncIdGenerator = mock(AsyncIdGenerator.class);
    SpanStorage storage = new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER);
    Trace trace = new DefaultTrace(callStackFactory, storage, traceId, 0L, asyncIdGenerator, true, spanFactory, recorderFactory);
    trace.traceBlockBegin();
    // get data form db
    getDataFromDB(trace);
    // response to client
    trace.traceBlockEnd();
}
Also used : DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) RecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.RecorderFactory) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) SpanStorage(com.navercorp.pinpoint.profiler.context.storage.SpanStorage) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) StringMetaDataService(com.navercorp.pinpoint.profiler.metadata.StringMetaDataService) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) SqlMetaDataService(com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService) AsyncIdGenerator(com.navercorp.pinpoint.profiler.context.id.AsyncIdGenerator) Test(org.junit.Test)

Example 3 with DefaultTraceId

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceId in project pinpoint by naver.

the class TraceTest method popEventTest.

@Test
public void popEventTest() {
    TraceId traceId = new DefaultTraceId("agent", 0, 1);
    CallStackFactory callStackFactory = new DefaultCallStackFactory(64);
    SpanFactory spanFactory = new DefaultSpanFactory("appName", "agentId", 0, ServiceType.STAND_ALONE);
    StringMetaDataService stringMetaDataService = mock(StringMetaDataService.class);
    SqlMetaDataService sqlMetaDataService = mock(SqlMetaDataService.class);
    RecorderFactory recorderFactory = new DefaultRecorderFactory(stringMetaDataService, sqlMetaDataService);
    AsyncIdGenerator asyncIdGenerator = mock(AsyncIdGenerator.class);
    TestDataSender dataSender = new TestDataSender();
    SpanStorage storage = new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER);
    Trace trace = new DefaultTrace(callStackFactory, storage, traceId, 0L, asyncIdGenerator, true, spanFactory, recorderFactory);
    trace.close();
    logger.debug(String.valueOf(dataSender.event));
}
Also used : DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) RecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.RecorderFactory) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) SpanStorage(com.navercorp.pinpoint.profiler.context.storage.SpanStorage) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) StringMetaDataService(com.navercorp.pinpoint.profiler.metadata.StringMetaDataService) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) SqlMetaDataService(com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService) AsyncIdGenerator(com.navercorp.pinpoint.profiler.context.id.AsyncIdGenerator) Test(org.junit.Test)

Example 4 with DefaultTraceId

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceId in project pinpoint by naver.

the class DefaultTraceTest method testPushPop.

@Test
public void testPushPop() {
    CallStackFactory callStackFactory = new DefaultCallStackFactory(64);
    SpanFactory spanFactory = new DefaultSpanFactory("appName", "agentId", 0, ServiceType.STAND_ALONE);
    StringMetaDataService stringMetaDataService = mock(StringMetaDataService.class);
    SqlMetaDataService sqlMetaDataService = mock(SqlMetaDataService.class);
    RecorderFactory recorderFactory = new DefaultRecorderFactory(stringMetaDataService, sqlMetaDataService);
    AsyncIdGenerator asyncIdGenerator = mock(AsyncIdGenerator.class);
    SpanStorage storage = new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER);
    long localTransactionId = 1;
    TraceId traceId = new DefaultTraceId("agentId", System.currentTimeMillis(), localTransactionId);
    Trace trace = new DefaultTrace(callStackFactory, storage, traceId, localTransactionId, asyncIdGenerator, true, spanFactory, recorderFactory);
    trace.traceBlockBegin();
    trace.traceBlockBegin();
    trace.traceBlockEnd();
    trace.traceBlockEnd();
    trace.close();
}
Also used : DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) RecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.RecorderFactory) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultRecorderFactory(com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory) SpanStorage(com.navercorp.pinpoint.profiler.context.storage.SpanStorage) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) StringMetaDataService(com.navercorp.pinpoint.profiler.metadata.StringMetaDataService) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) SqlMetaDataService(com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService) AsyncIdGenerator(com.navercorp.pinpoint.profiler.context.id.AsyncIdGenerator)

Example 5 with DefaultTraceId

use of com.navercorp.pinpoint.profiler.context.id.DefaultTraceId in project pinpoint by naver.

the class SpanEventTest method testMarkStartTime.

@Test
public void testMarkStartTime() throws Exception {
    final DefaultTraceId traceId = new DefaultTraceId("agentTime", 0, 0);
    Span span = new Span();
    span.setAgentId("agentId");
    span.recordTraceId(traceId);
    span.markBeforeTime();
    Thread.sleep(10);
    span.markAfterTime();
    logger.debug("span:{}", span);
    final SpanEvent spanEvent = new SpanEvent(span);
    spanEvent.markStartTime();
    Thread.sleep(10);
    spanEvent.markAfterTime();
    logger.debug("spanEvent:{}", spanEvent);
    Assert.assertEquals("startTime", span.getStartTime() + spanEvent.getStartElapsed(), spanEvent.getStartTime());
    Assert.assertEquals("endTime", span.getStartTime() + spanEvent.getStartElapsed() + spanEvent.getEndElapsed(), spanEvent.getAfterTime());
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) Test(org.junit.Test)

Aggregations

DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)11 Test (org.junit.Test)8 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)7 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)3 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)3 AsyncIdGenerator (com.navercorp.pinpoint.profiler.context.id.AsyncIdGenerator)3 DefaultRecorderFactory (com.navercorp.pinpoint.profiler.context.recorder.DefaultRecorderFactory)3 RecorderFactory (com.navercorp.pinpoint.profiler.context.recorder.RecorderFactory)3 SpanStorage (com.navercorp.pinpoint.profiler.context.storage.SpanStorage)3 SqlMetaDataService (com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService)3 StringMetaDataService (com.navercorp.pinpoint.profiler.metadata.StringMetaDataService)3 Span (com.navercorp.pinpoint.profiler.context.Span)2 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)2 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)2 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)1 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)1 AsyncTraceId (com.navercorp.pinpoint.bootstrap.context.AsyncTraceId)1 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)1 StandardHostValveInvokeInterceptor (com.navercorp.pinpoint.plugin.jboss.interceptor.StandardHostValveInvokeInterceptor)1 StandardHostValveInvokeInterceptor (com.navercorp.pinpoint.plugin.tomcat.interceptor.StandardHostValveInvokeInterceptor)1