Search in sources :

Example 1 with StringMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.StringMetaDataService 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 2 with StringMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.StringMetaDataService 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 3 with StringMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.StringMetaDataService in project pinpoint by naver.

the class DefaultSpanRecorderTest method testRecordApiId.

@Test
public void testRecordApiId() throws Exception {
    Span span = new Span();
    StringMetaDataService stringMetaDataService = Mockito.mock(StringMetaDataService.class);
    SqlMetaDataService sqlMetaDataService = Mockito.mock(SqlMetaDataService.class);
    SpanRecorder recorder = new DefaultSpanRecorder(span, true, true, stringMetaDataService, sqlMetaDataService);
    final int API_ID = 1000;
    recorder.recordApiId(API_ID);
    Assert.assertEquals("API ID", span.getApiId(), API_ID);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) StringMetaDataService(com.navercorp.pinpoint.profiler.metadata.StringMetaDataService) SqlMetaDataService(com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 4 with StringMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.StringMetaDataService in project pinpoint by naver.

the class WrappedSpanEventRecorderTest method testSetExceptionInfo_RootMarkError.

@Test
public void testSetExceptionInfo_RootMarkError() throws Exception {
    Span span = new Span();
    SpanEvent spanEvent = new SpanEvent(span);
    StringMetaDataService stringMetaDataService = Mockito.mock(StringMetaDataService.class);
    SqlMetaDataService sqlMetaDataService = Mockito.mock(SqlMetaDataService.class);
    WrappedSpanEventRecorder recorder = new WrappedSpanEventRecorder(stringMetaDataService, sqlMetaDataService);
    recorder.setWrapped(spanEvent);
    final String exceptionMessage1 = "exceptionMessage1";
    final Exception exception1 = new Exception(exceptionMessage1);
    recorder.recordException(false, exception1);
    Assert.assertEquals("Exception recoding", exceptionMessage1, spanEvent.getExceptionInfo().getStringValue());
    Assert.assertFalse("markRootError=false", span.isSetErrCode());
    final String exceptionMessage2 = "exceptionMessage2";
    final Exception exception2 = new Exception(exceptionMessage2);
    recorder.recordException(true, exception2);
    Assert.assertEquals("Exception recoding", exceptionMessage2, spanEvent.getExceptionInfo().getStringValue());
    Assert.assertTrue("markRootError=true", span.isSetErrCode());
}
Also used : StringMetaDataService(com.navercorp.pinpoint.profiler.metadata.StringMetaDataService) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) SqlMetaDataService(com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 5 with StringMetaDataService

use of com.navercorp.pinpoint.profiler.metadata.StringMetaDataService 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)

Aggregations

SqlMetaDataService (com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService)6 StringMetaDataService (com.navercorp.pinpoint.profiler.metadata.StringMetaDataService)6 Test (org.junit.Test)5 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)3 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 Span (com.navercorp.pinpoint.profiler.context.Span)3 AsyncIdGenerator (com.navercorp.pinpoint.profiler.context.id.AsyncIdGenerator)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)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 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)2 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)1