Search in sources :

Example 11 with SpanEvent

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

the class BufferedStorageTest method testStore_manual_flush.

@Test
public void testStore_manual_flush() throws Exception {
    BufferedStorage bufferedStorage = newBufferedStorage(10);
    Span span = new Span(internalTraceId);
    SpanEvent spanEvent = new SpanEvent();
    bufferedStorage.store(spanEvent);
    bufferedStorage.store(spanEvent);
    bufferedStorage.flush();
    Assert.assertEquals(1, countingDataSender.getSenderCounter());
    Assert.assertEquals(1, countingDataSender.getTotalCount());
    Assert.assertEquals(0, countingDataSender.getSpanCounter());
    Assert.assertEquals(1, countingDataSender.getSpanChunkCounter());
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 12 with SpanEvent

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

the class BufferedStorageTest method testStore_Noflush.

@Test
public void testStore_Noflush() throws Exception {
    BufferedStorage bufferedStorage = newBufferedStorage(10);
    Span span = new Span(internalTraceId);
    SpanEvent spanEvent = new SpanEvent();
    bufferedStorage.store(spanEvent);
    bufferedStorage.store(spanEvent);
    Assert.assertEquals(0, countingDataSender.getTotalCount());
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 13 with SpanEvent

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

the class SpanThriftMessageConverterTest method buildTSpanEvent.

@Test
public void buildTSpanEvent() {
    final long startTime = System.currentTimeMillis() - 100;
    SpanEvent spanEvent = new SpanEvent();
    spanEvent.setDepth(RandomExUtils.nextInt(0, 100));
    spanEvent.setStartTime(startTime + RandomExUtils.nextInt(0, 100));
    spanEvent.setAfterTime(spanEvent.getStartTime() + RandomExUtils.nextInt(5, 100));
    spanEvent.setDestinationId("destinationId");
    spanEvent.setSequence(RandomExUtils.nextInt(0, 100));
    spanEvent.setNextSpanId(RandomExUtils.nextInt(0, 100));
    spanEvent.setAsyncIdObject(new DefaultAsyncId(RandomExUtils.nextInt(0, 100)));
    spanEvent.addAnnotation(Annotations.of(1));
    TSpanEvent tSpanEvent = messageConverter.buildTSpanEvent(spanEvent);
    spanPostProcessor.postEventProcess(Collections.singletonList(spanEvent), Collections.singletonList(tSpanEvent), startTime);
    Assert.assertEquals(spanEvent.getDepth(), tSpanEvent.getDepth());
    Assert.assertEquals(spanEvent.getStartTime(), startTime + tSpanEvent.getStartElapsed());
    Assert.assertEquals(spanEvent.getAfterTime(), startTime + tSpanEvent.getStartElapsed() + tSpanEvent.getEndElapsed());
    Assert.assertEquals(spanEvent.getDestinationId(), tSpanEvent.getDestinationId());
    Assert.assertEquals(spanEvent.getSequence(), tSpanEvent.getSequence());
    Assert.assertEquals(spanEvent.getNextSpanId(), tSpanEvent.getNextSpanId());
    Assert.assertEquals(spanEvent.getAsyncIdObject().getAsyncId(), tSpanEvent.getNextAsyncId());
    Assert.assertEquals(spanEvent.getAnnotations().size(), tSpanEvent.getAnnotations().size());
}
Also used : DefaultAsyncId(com.navercorp.pinpoint.profiler.context.DefaultAsyncId) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 14 with SpanEvent

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

the class SpanThriftMessageConverterTest method buildTSpan.

@Test
public void buildTSpan() {
    final Span span = newSpan();
    span.setStartTime(System.currentTimeMillis());
    span.setElapsedTime(RandomExUtils.nextInt(0, 100));
    span.setAcceptorHost("acceptorHost");
    span.setExceptionInfo(new IntStringValue(RandomExUtils.nextInt(0, 100), "error"));
    span.setApiId(RandomExUtils.nextInt(0, 100));
    span.setServiceType((short) RandomExUtils.nextInt(0, 100));
    span.setRemoteAddr("remoteAddr");
    span.setParentApplicationName("pApp");
    span.setParentApplicationType((short) RandomExUtils.nextInt(0, 100));
    final TraceRoot traceRoot = span.getTraceRoot();
    Shared shared = traceRoot.getShared();
    shared.setEndPoint("endPoint");
    shared.setRpcName("rpcName");
    shared.setLoggingInfo((byte) RandomExUtils.nextInt(0, 10));
    shared.maskErrorCode(RandomExUtils.nextInt(0, 100));
    shared.setStatusCode(RandomExUtils.nextInt(0, 100));
    span.addAnnotation(Annotations.of(1));
    span.setSpanEventList(Collections.singletonList(new SpanEvent()));
    final TSpan tSpan = messageConverter.buildTSpan(span);
    Assert.assertEquals(span.getStartTime(), tSpan.getStartTime());
    Assert.assertEquals(span.getElapsedTime(), tSpan.getElapsed());
    Assert.assertEquals(span.getAcceptorHost(), tSpan.getAcceptorHost());
    Assert.assertEquals(span.getExceptionInfo().getIntValue(), tSpan.getExceptionInfo().getIntValue());
    Assert.assertEquals(span.getExceptionInfo().getStringValue(), tSpan.getExceptionInfo().getStringValue());
    Assert.assertEquals(span.getApiId(), tSpan.getApiId());
    Assert.assertEquals(span.getServiceType(), tSpan.getServiceType());
    Assert.assertEquals(span.getRemoteAddr(), tSpan.getRemoteAddr());
    Assert.assertEquals(span.getParentApplicationName(), tSpan.getParentApplicationName());
    Assert.assertEquals(span.getParentApplicationType(), tSpan.getParentApplicationType());
    Assert.assertEquals(traceRoot.getTraceId().getSpanId(), tSpan.getSpanId());
    Assert.assertEquals(traceRoot.getShared().getEndPoint(), tSpan.getEndPoint());
    Assert.assertEquals(traceRoot.getShared().getRpcName(), tSpan.getRpc());
    Assert.assertEquals(traceRoot.getShared().getLoggingInfo(), tSpan.getLoggingTransactionInfo());
    Assert.assertEquals(traceRoot.getShared().getErrorCode(), tSpan.getErr());
    // TODO
    // Assert.assertEquals(traceRoot.getShared().getStatusCode(),  );
    Assert.assertEquals(span.getAnnotations().size(), tSpan.getAnnotations().size());
    Assert.assertEquals(span.getSpanEventList().size(), tSpan.getSpanEventList().size());
}
Also used : IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) 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) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 15 with SpanEvent

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

the class SpanThriftMessageConverterTest method newSpanChunk.

private SpanChunk newSpanChunk() {
    final TraceId traceId = new DefaultTraceId(AGENT_ID, AGENT_START_TIME, 1L);
    final TraceRoot traceRoot = new DefaultTraceRoot(traceId, AGENT_ID, AGENT_START_TIME, 100L);
    return new DefaultSpanChunk(traceRoot, Arrays.asList(new SpanEvent()));
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)

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