Search in sources :

Example 1 with DefaultAsyncId

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

Aggregations

DefaultAsyncId (com.navercorp.pinpoint.profiler.context.DefaultAsyncId)1 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)1 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)1 Test (org.junit.Test)1