Search in sources :

Example 16 with SpanEvent

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

the class WrappedSpanEventRecorderTest method testSetExceptionInfo_RootMarkError.

@Test
public void testSetExceptionInfo_RootMarkError() throws Exception {
    when(traceRoot.getShared()).thenReturn(shared);
    SpanEvent spanEvent = new SpanEvent();
    WrappedSpanEventRecorder recorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler);
    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());
    verify(shared, never()).maskErrorCode(anyInt());
    final String exceptionMessage2 = "exceptionMessage2";
    final Exception exception2 = new Exception(exceptionMessage2);
    recorder.recordException(true, exception2);
    Assert.assertEquals("Exception recoding", exceptionMessage2, spanEvent.getExceptionInfo().getStringValue());
    verify(shared, only()).maskErrorCode(1);
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) Test(org.junit.Test)

Example 17 with SpanEvent

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

the class SpanPostProcessorTest method addSpanEvent.

private void addSpanEvent(List<TSpanEvent> tSpanEvents, List<SpanEvent> spanEvents) {
    spanEvents.add(new SpanEvent());
    tSpanEvents.add(new TSpanEvent());
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 18 with SpanEvent

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

the class SpanPostProcessorTest method postProcess1.

@Test
public void postProcess1() {
    SpanProcessor<TSpan, TSpanChunk> spanChunkPostProcessor = new SpanProcessorV1();
    TraceRoot internalTraceId = newInternalTraceId();
    TSpanChunk tSpanChunk = new TSpanChunk();
    try {
        SpanChunk spanChunk = new DefaultSpanChunk(internalTraceId, new ArrayList<SpanEvent>());
        spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
        Assert.fail();
    } catch (Exception ignored) {
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) Test(org.junit.Test)

Example 19 with SpanEvent

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

the class GrpcSpanProcessorV2Test method postProcess.

@Test
public void postProcess() {
    Span span = newSpan();
    SpanEventBuilder factory = new SpanEventBuilder();
    factory.addSpanEvent();
    factory.addSpanEvent();
    factory.addSpanEvent();
    span.setSpanEventList(factory.getSpanEventList());
    PSpan.Builder builder = PSpan.newBuilder();
    for (SpanEvent spanEvent : span.getSpanEventList()) {
        PSpanEvent.Builder pSpanEvent = converter.buildPSpanEvent(spanEvent);
        builder.addSpanEvent(pSpanEvent);
    }
    spanProcessorProtoV2.postProcess(span, builder);
    PSpan pSpan = builder.build();
    List<PSpanEvent> pSpanEventList = pSpan.getSpanEventList();
    List<SpanEvent> spanEventList = span.getSpanEventList();
    long keyStartTime = span.getStartTime();
    for (int i = 0; i < pSpanEventList.size(); i++) {
        PSpanEvent pSpanEvent = pSpanEventList.get(i);
        SpanEvent next = spanEventList.get(i);
        long startTime = keyStartTime + pSpanEvent.getStartElapsed();
        Assert.assertEquals(startTime, next.getStartTime());
        keyStartTime = startTime;
    }
}
Also used : PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) PSpan(com.navercorp.pinpoint.grpc.trace.PSpan) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 20 with SpanEvent

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

the class InformixConnectionIT method execute.

@Test
public void execute() throws SQLException {
    Connection connection = null;
    try {
        connection = createConnection("localhost:" + container.getFirstMappedPort() + "/sysmaster", "informix", "in4mix");
        statement(connection);
        preparedStatement2(connection);
        preparedStatement3(connection);
        preparedStatement4(connection);
        preparedStatement5(connection);
        preparedStatement6(connection);
        preparedStatement7(connection);
        preparedStatement8(connection);
        List<SpanEvent> currentSpanEvents = getCurrentSpanEvents();
        LOGGER.info("{}", currentSpanEvents);
    } finally {
        if (connection != null) {
            connection.close();
        }
    }
}
Also used : Connection(java.sql.Connection) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) BasePinpointTest(com.navercorp.pinpoint.test.junit4.BasePinpointTest) Test(org.junit.Test)

Aggregations

SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)49 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)23 Test (org.junit.Test)20 Span (com.navercorp.pinpoint.profiler.context.Span)18 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)10 ArrayList (java.util.ArrayList)10 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)9 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)7 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)6 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)6 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)5 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)5 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)5 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)4 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)4 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)3 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3