Search in sources :

Example 16 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.

the class RandomTSpan method randomTSpanEvent.

public TSpanEvent randomTSpanEvent(short sequence) {
    TSpanEvent tSpanEvent = new TSpanEvent();
    //        @deprecated
    //        tSpanEvent.setSpanId();
    tSpanEvent.setSequence(sequence);
    tSpanEvent.setStartElapsed(RandomUtils.nextInt(0, 1000));
    tSpanEvent.setEndElapsed(RandomUtils.nextInt(0, 1000));
    tSpanEvent.setRpc(RandomStringUtils.random(10));
    //         Database (2000 ~ 2899)
    tSpanEvent.setServiceType((short) RandomUtils.nextInt(2000, 2889));
    tSpanEvent.setEndPoint(RandomStringUtils.random(10));
    List<TAnnotation> tAnnotationList = randomTAnnotationList();
    if (CollectionUtils.isNotEmpty(tAnnotationList)) {
        tSpanEvent.setAnnotations(tAnnotationList);
    }
    tSpanEvent.setDepth(RandomUtils.nextInt(0, 256));
    tSpanEvent.setNextSpanId(random.nextLong());
    tSpanEvent.setDestinationId(RandomStringUtils.random(20));
    tSpanEvent.setApiId(RandomUtils.nextInt(0, 65535));
    tSpanEvent.setAsyncId(randomNegative(RandomUtils.nextInt(0, 10)));
    tSpanEvent.setNextAsyncId(random.nextInt());
    tSpanEvent.setAsyncSequence((short) RandomUtils.nextInt(0, Short.MAX_VALUE));
    if (random.nextBoolean()) {
        TIntStringValue exceptionInfo = new TIntStringValue();
        exceptionInfo.setIntValue(RandomUtils.nextInt(0, 5000));
        exceptionInfo.setStringValue(RandomStringUtils.random(100));
        tSpanEvent.setExceptionInfo(exceptionInfo);
    }
    return tSpanEvent;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation)

Example 17 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.

the class SpanFactoryAssert method assertSpan.

public void assertSpan(TSpan tSpan, SpanBo spanBo) {
    Assert.assertEquals(tSpan.getAgentId(), spanBo.getAgentId());
    Assert.assertEquals(tSpan.getApplicationName(), spanBo.getApplicationId());
    Assert.assertEquals(tSpan.getAgentStartTime(), spanBo.getAgentStartTime());
    TransactionId transactionId = spanBo.getTransactionId();
    ByteBuffer byteBuffer = TransactionIdUtils.formatByteBuffer(transactionId.getAgentId(), transactionId.getAgentStartTime(), transactionId.getTransactionSequence());
    Assert.assertEquals(ByteBuffer.wrap(tSpan.getTransactionId()), byteBuffer);
    Assert.assertEquals(tSpan.getSpanId(), spanBo.getSpanId());
    Assert.assertEquals(tSpan.getParentSpanId(), spanBo.getParentSpanId());
    Assert.assertEquals(tSpan.getStartTime(), spanBo.getStartTime());
    Assert.assertEquals(tSpan.getElapsed(), spanBo.getElapsed());
    Assert.assertEquals(tSpan.getElapsed(), spanBo.getElapsed());
    Assert.assertEquals(tSpan.getRpc(), spanBo.getRpc());
    Assert.assertEquals(tSpan.getServiceType(), spanBo.getServiceType());
    Assert.assertEquals(tSpan.getEndPoint(), spanBo.getEndPoint());
    Assert.assertEquals(tSpan.getRemoteAddr(), spanBo.getRemoteAddr());
    assertAnnotation(tSpan.getAnnotations(), spanBo.getAnnotationBoList());
    Assert.assertEquals(tSpan.getFlag(), spanBo.getFlag());
    Assert.assertEquals(tSpan.getErr(), spanBo.getErrCode());
    Assert.assertEquals(tSpan.getParentApplicationName(), spanBo.getParentApplicationId());
    Assert.assertEquals(tSpan.getParentApplicationType(), spanBo.getParentApplicationServiceType());
    Assert.assertEquals(tSpan.getAcceptorHost(), spanBo.getAcceptorHost());
    Assert.assertEquals(tSpan.getApiId(), spanBo.getApiId());
    Assert.assertEquals(tSpan.getApplicationServiceType(), spanBo.getApplicationServiceType());
    List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
    List<TSpanEvent> spanEventList = tSpan.getSpanEventList();
    assertSpanEventList(spanEventBoList, spanEventList);
    boolean hasException = tSpan.getExceptionInfo() != null;
    Assert.assertEquals(hasException, spanBo.hasException());
    if (hasException) {
        Assert.assertEquals(tSpan.getExceptionInfo().getIntValue(), spanBo.getExceptionId());
        Assert.assertEquals(tSpan.getExceptionInfo().getStringValue(), spanBo.getExceptionMessage());
    }
    Assert.assertEquals(tSpan.getLoggingTransactionInfo(), spanBo.getLoggingTransactionInfo());
}
Also used : ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 18 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.

the class SpanFactoryAssert method assertSpanChunk.

public void assertSpanChunk(TSpanChunk tSpanChunk, SpanChunkBo spanChunkBo) {
    Assert.assertEquals(tSpanChunk.getAgentId(), spanChunkBo.getAgentId());
    Assert.assertEquals(tSpanChunk.getApplicationName(), spanChunkBo.getApplicationId());
    Assert.assertEquals(tSpanChunk.getAgentStartTime(), spanChunkBo.getAgentStartTime());
    TransactionId transactionId = spanChunkBo.getTransactionId();
    ByteBuffer byteBuffer = TransactionIdUtils.formatByteBuffer(transactionId.getAgentId(), transactionId.getAgentStartTime(), transactionId.getTransactionSequence());
    Assert.assertEquals(ByteBuffer.wrap(tSpanChunk.getTransactionId()), byteBuffer);
    Assert.assertEquals(tSpanChunk.getSpanId(), spanChunkBo.getSpanId());
    Assert.assertEquals(tSpanChunk.getServiceType(), spanChunkBo.getServiceType());
    Assert.assertEquals(tSpanChunk.getEndPoint(), spanChunkBo.getEndPoint());
    Assert.assertEquals(tSpanChunk.getApplicationServiceType(), spanChunkBo.getApplicationServiceType());
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    List<TSpanEvent> spanEventList = tSpanChunk.getSpanEventList();
    assertSpanEventList(spanEventBoList, spanEventList);
}
Also used : ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 19 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.

the class SpanFactoryTest method testBuildSpanBo.

@Test
public void testBuildSpanBo() throws Exception {
    TSpan tSpan = random.randomTSpan();
    TSpanEvent tSpanEvent1 = random.randomTSpanEvent((short) 0);
    TSpanEvent tSpanEvent2 = random.randomTSpanEvent((short) 1);
    TSpanEvent tSpanEvent3 = random.randomTSpanEvent((short) 5);
    TSpanEvent tSpanEvent4 = random.randomTSpanEvent((short) 2);
    tSpan.setSpanEventList(Lists.newArrayList(tSpanEvent1, tSpanEvent2, tSpanEvent3, tSpanEvent4));
    SpanBo spanBo = spanFactory.buildSpanBo(tSpan);
    spanFactoryAssert.assertSpan(tSpan, spanBo);
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 20 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.

the class SpanEncoderTest method randomComplexSpan.

public SpanBo randomComplexSpan() {
    TSpan tSpan = randomTSpan.randomTSpan();
    TSpanEvent tSpanEvent1 = randomTSpan.randomTSpanEvent((short) 1);
    TSpanEvent tSpanEvent2 = randomTSpan.randomTSpanEvent((short) 2);
    TSpanEvent tSpanEvent3 = randomTSpan.randomTSpanEvent((short) 3);
    TSpanEvent tSpanEvent4 = randomTSpan.randomTSpanEvent((short) 5);
    tSpan.setSpanEventList(Lists.newArrayList(tSpanEvent1, tSpanEvent2, tSpanEvent3, tSpanEvent4));
    return spanFactory.buildSpanBo(tSpan);
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) RandomTSpan(com.navercorp.pinpoint.common.server.bo.RandomTSpan) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Aggregations

TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)30 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 ByteBuffer (java.nio.ByteBuffer)8 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)7 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)6 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)4 HeaderTBaseDeserializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)4 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)4 Span (com.navercorp.pinpoint.profiler.context.Span)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)2 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)2 PartitionedByteBufferLocator (com.navercorp.pinpoint.profiler.sender.PartitionedByteBufferLocator)2 SpanStreamSendData (com.navercorp.pinpoint.profiler.sender.SpanStreamSendData)2 SpanStreamSendDataFactory (com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataFactory)2 SpanStreamSendDataSerializer (com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataSerializer)2 TBase (org.apache.thrift.TBase)2 TException (org.apache.thrift.TException)2 RandomTSpan (com.navercorp.pinpoint.common.server.bo.RandomTSpan)1