Search in sources :

Example 1 with TSpanEvent

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

the class SpanFactoryAssert method assertSpanEventList.

private void assertSpanEventList(List<SpanEventBo> spanEventBoList, List<TSpanEvent> spanEventList) {
    Assert.assertEquals(CollectionUtils.isEmpty(spanEventBoList), CollectionUtils.isEmpty(spanEventList));
    if (CollectionUtils.isNotEmpty(spanEventBoList)) {
        Map<Long, SpanEventBo> spanEventBoMap = new HashMap<Long, SpanEventBo>();
        for (int i = 0; i < spanEventBoList.size(); i++) {
            SpanEventBo spanEventBo = spanEventBoList.get(i);
            spanEventBoMap.put((long) spanEventBo.getSequence(), spanEventBo);
        }
        for (int i = 0; i < spanEventList.size(); i++) {
            TSpanEvent tSpanEvent = spanEventList.get(i);
            SpanEventBo spanEventBo = spanEventBoMap.get((long) tSpanEvent.getSequence());
            Assert.assertNotNull(spanEventBo);
            assertSpanEvent(tSpanEvent, spanEventBo);
        }
    }
}
Also used : HashMap(java.util.HashMap) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 2 with TSpanEvent

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

the class SpanFactoryTest method testBuildSpanChunkBo.

@Test
public void testBuildSpanChunkBo() throws Exception {
    TSpanChunk tSpanChunk = random.randomTSpanChunk();
    TSpanEvent tSpanEvent1 = random.randomTSpanEvent((short) 0);
    TSpanEvent tSpanEvent2 = random.randomTSpanEvent((short) 1);
    TSpanEvent tSpanEvent3 = random.randomTSpanEvent((short) 5);
    TSpanEvent tSpanEvent4 = random.randomTSpanEvent((short) 2);
    tSpanChunk.setSpanEventList(Lists.newArrayList(tSpanEvent1, tSpanEvent2, tSpanEvent3, tSpanEvent4));
    SpanChunkBo spanChunkBo = spanFactory.buildSpanChunkBo(tSpanChunk);
    spanFactoryAssert.assertSpanChunk(tSpanChunk, spanChunkBo);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 3 with TSpanEvent

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

the class SpanFactory method buildSpanEventBoList.

private List<SpanEventBo> buildSpanEventBoList(List<TSpanEvent> spanEventList) {
    if (CollectionUtils.isEmpty(spanEventList)) {
        return new ArrayList<SpanEventBo>();
    }
    List<SpanEventBo> spanEventBoList = new ArrayList<SpanEventBo>(spanEventList.size());
    for (TSpanEvent tSpanEvent : spanEventList) {
        final SpanEventBo spanEventBo = buildSpanEventBo(tSpanEvent);
        if (!spanEventFilter.filter(spanEventBo)) {
            continue;
        }
        spanEventBoList.add(spanEventBo);
    }
    Collections.sort(spanEventBoList, SpanEventComparator.INSTANCE);
    return spanEventBoList;
}
Also used : ArrayList(java.util.ArrayList) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 4 with TSpanEvent

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

the class SpanStreamUDPSenderTest method createSpan.

private Span createSpan(int spanEventSize) throws InterruptedException {
    List<SpanEvent> spanEventList = createSpanEventList(spanEventSize);
    Span span = new Span();
    List<TSpanEvent> tSpanEventList = new ArrayList<>();
    for (SpanEvent spanEvent : spanEventList) {
        tSpanEventList.add(spanEvent);
    }
    span.setSpanEventList(tSpanEventList);
    return span;
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) ArrayList(java.util.ArrayList) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 5 with TSpanEvent

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

the class ChunkHeaderBufferedTBaseSerializer method addTSpan.

// TSpan = TSpan + TSpanChunk
private void addTSpan(TBase<?, ?> base) throws TException {
    final TSpan span = (TSpan) base;
    if (span.getSpanEventList() == null) {
        write(base);
        return;
    }
    try {
        for (TSpanEvent e : span.getSpanEventList()) {
            eventStream.write(e);
        }
        write(span, FIELD_NAME_SPAN_EVENT_LIST, eventStream.split(chunkSize));
        while (!eventStream.isEmpty()) {
            final TSpanChunk spanChunk = toSpanChunk(span);
            write(spanChunk, FIELD_NAME_SPAN_EVENT_LIST, eventStream.split(chunkSize));
        }
    } finally {
        eventStream.clear();
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) 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