Search in sources :

Example 6 with TSpan

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

the class SpanStreamUDPSenderTest method createSpanEventList.

private List<SpanEvent> createSpanEventList(int size) throws InterruptedException {
    // Span span = new SpanBo(new TSpan());
    Span span = new Span();
    List<SpanEvent> spanEventList = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        SpanEvent spanEvent = new SpanEvent(span);
        spanEvent.markStartTime();
        Thread.sleep(1);
        spanEvent.markAfterTime();
        spanEventList.add(spanEvent);
    }
    return spanEventList;
}
Also used : ArrayList(java.util.ArrayList) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 7 with TSpan

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

the class SpanFactoryTest method testNewSpanBo.

@Test
public void testNewSpanBo() throws Exception {
    TSpan tSpan = random.randomTSpan();
    SpanBo spanBo = spanFactory.newSpanBo(tSpan);
    spanFactoryAssert.assertSpan(tSpan, spanBo);
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Test(org.junit.Test)

Example 8 with TSpan

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

the class RandomTSpan method randomTSpan.

public TSpan randomTSpan() {
    final TSpan tSpan = new TSpan();
    tSpan.setAgentId("agentId");
    tSpan.setApplicationName("appName");
    tSpan.setAgentStartTime(System.currentTimeMillis());
    tSpan.setTransactionId(TransactionIdUtils.formatByteBuffer("agent", System.currentTimeMillis(), RandomUtils.nextLong(0, Long.MAX_VALUE)));
    tSpan.setSpanId(random.nextLong());
    tSpan.setParentSpanId(RandomUtils.nextInt(0, 100000));
    tSpan.setStartTime(System.currentTimeMillis() + RandomUtils.nextInt(0, 1000));
    tSpan.setElapsed(RandomUtils.nextInt(0, 2000));
    tSpan.setRpc(RandomStringUtils.random(10));
    tSpan.setServiceType(randomServerServiceType());
    tSpan.setEndPoint(RandomStringUtils.random(20));
    tSpan.setRemoteAddr(RandomStringUtils.random(20));
    List<TAnnotation> tAnnotationList = randomTAnnotationList();
    if (CollectionUtils.isNotEmpty(tAnnotationList)) {
        tSpan.setAnnotations(tAnnotationList);
    }
    tSpan.setFlag((short) RandomUtils.nextInt(0, 4));
    tSpan.setErr((short) RandomUtils.nextInt(0, 2));
    //        tSpan.setSpanEventList()
    tSpan.setParentApplicationName("parentApp");
    tSpan.setParentApplicationType(randomServerServiceType());
    tSpan.setAcceptorHost("acceptHost");
    tSpan.setApiId(RandomUtils.nextInt(0, 5000));
    if (random.nextBoolean()) {
        tSpan.setApplicationServiceType(randomServerServiceType());
    } else {
        tSpan.setApplicationServiceType(tSpan.getServiceType());
    }
    if (random.nextBoolean()) {
        TIntStringValue exceptionInfo = new TIntStringValue();
        exceptionInfo.setIntValue(RandomUtils.nextInt(0, 5000));
        exceptionInfo.setStringValue(RandomStringUtils.random(100));
        tSpan.setExceptionInfo(exceptionInfo);
    }
    tSpan.setLoggingTransactionInfo((byte) RandomUtils.nextInt(0, 256));
    return tSpan;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation)

Example 9 with TSpan

use of com.navercorp.pinpoint.thrift.dto.TSpan 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 10 with TSpan

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

the class SpanFactoryTest method testTransactionId_skip_agentId.

@Test
public void testTransactionId_skip_agentId() throws Exception {
    TSpan tSpan = new TSpan();
    tSpan.setAgentId("agentId");
    byte[] transactionIdBytes = TransactionIdUtils.formatBytes(null, 1, 2);
    tSpan.setTransactionId(transactionIdBytes);
    SpanBo spanBo = spanFactory.newSpanBo(tSpan);
    TransactionId transactionId = spanBo.getTransactionId();
    Assert.assertEquals(transactionId.getAgentId(), "agentId");
    Assert.assertEquals(transactionId.getAgentStartTime(), 1);
    Assert.assertEquals(transactionId.getTransactionSequence(), 2);
}
Also used : TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) Test(org.junit.Test)

Aggregations

TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)16 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)6 Test (org.junit.Test)6 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)2 Span (com.navercorp.pinpoint.profiler.context.Span)2 RandomTSpan (com.navercorp.pinpoint.common.server.bo.RandomTSpan)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)1 TAnnotation (com.navercorp.pinpoint.thrift.dto.TAnnotation)1 TIntStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringValue)1 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)1 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)1 HeaderTBaseDeserializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)1 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 TException (org.apache.thrift.TException)1