Search in sources :

Example 31 with SpanEvent

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

the class SpanStreamSendDataSerializerTest method createSpan.

private Span createSpan(List<SpanEvent> spanEventList) {
    DefaultTraceId traceId = new DefaultTraceId("test", 0, 1);
    Span span = new Span();
    for (SpanEvent spanEvent : spanEventList) {
        span.addToSpanEventList(spanEvent);
    }
    span.setAgentId("agentId");
    span.recordTraceId(traceId);
    return span;
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) 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 32 with SpanEvent

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

the class SpanStreamSendDataSerializerTest method createSpanEventList.

private List<SpanEvent> createSpanEventList(int size) throws InterruptedException {
    Span span = new Span();
    List<SpanEvent> spanEventList = new ArrayList<SpanEvent>(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 33 with SpanEvent

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

the class SpanChunkStreamSendDataPlanerTest method spanChunkStreamSendDataPlanerTest.

@Test
public void spanChunkStreamSendDataPlanerTest() throws Exception {
    int spanEventSize = 10;
    SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
    HeaderTBaseSerializerFactory headerTBaseSerializerFactory = new HeaderTBaseSerializerFactory();
    List<SpanEvent> originalSpanEventList = createSpanEventList(spanEventSize);
    SpanChunk spanChunk = spanChunkFactory.create(originalSpanEventList);
    PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
    SpanStreamSendDataFactory factory = new SpanStreamSendDataFactory(100, 50, objectPool);
    List<TSpanEvent> spanEventList = getSpanEventList(partitionedByteBufferLocator, factory);
    partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
    factory = new SpanStreamSendDataFactory(objectPool);
    List<TSpanEvent> spanEventList2 = getSpanEventList(partitionedByteBufferLocator, factory);
    Assert.assertEquals(spanEventSize, spanEventList.size());
    Assert.assertEquals(spanEventSize, spanEventList2.size());
}
Also used : SpanStreamSendDataFactory(com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataFactory) SpanStreamSendDataSerializer(com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataSerializer) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) PartitionedByteBufferLocator(com.navercorp.pinpoint.profiler.sender.PartitionedByteBufferLocator) Test(org.junit.Test)

Example 34 with SpanEvent

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

the class GrpcSpanMessageConverter method buildPSpanEventList.

private List<PSpanEvent> buildPSpanEventList(List<SpanEvent> spanEventList) {
    final int eventSize = spanEventList.size();
    final List<PSpanEvent> pSpanEventList = new ArrayList<>(eventSize);
    for (SpanEvent spanEvent : spanEventList) {
        final PSpanEvent.Builder pSpanEvent = buildPSpanEvent(spanEvent);
        pSpanEventList.add(pSpanEvent.build());
    }
    return pSpanEventList;
}
Also used : ArrayList(java.util.ArrayList) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 35 with SpanEvent

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

the class GrpcSpanProcessorV2 method postProcess.

private void postProcess(long keyTime, List<SpanEvent> spanEventList, List<PSpanEvent.Builder> pSpanEventList) {
    final int spanEventSize = CollectionUtils.nullSafeSize(spanEventList);
    if (spanEventSize == 0) {
        return;
    }
    if (!(spanEventSize == CollectionUtils.nullSafeSize(pSpanEventList))) {
        throw new IllegalStateException("list size not same");
    }
    // check list type
    assert spanEventList instanceof RandomAccess;
    int prevDepth = 0;
    boolean first = true;
    final int listSize = spanEventList.size();
    for (int i = 0; i < listSize; i++) {
        final SpanEvent spanEvent = spanEventList.get(i);
        final PSpanEvent.Builder pSpanEvent = pSpanEventList.get(i);
        final long startTime = spanEvent.getStartTime();
        final long startElapsedTime = startTime - keyTime;
        pSpanEvent.setStartElapsed((int) startElapsedTime);
        keyTime = startTime;
        if (first) {
            first = false;
            int depth = spanEvent.getDepth();
            prevDepth = depth;
            pSpanEvent.setDepth(depth);
        } else {
            int currentDepth = spanEvent.getDepth();
            if (currentDepth == prevDepth) {
                // skip
                pSpanEvent.setDepth(0);
            } else {
                pSpanEvent.setDepth(currentDepth);
            }
            prevDepth = currentDepth;
        }
    }
}
Also used : PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) RandomAccess(java.util.RandomAccess) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

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