Search in sources :

Example 11 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent 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 12 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent 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)

Example 13 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.

the class GrpcSpanChunkHandler method createSimpleSpanChunkLog.

private String createSimpleSpanChunkLog(PSpanChunk spanChunk) {
    if (!isDebug) {
        return "";
    }
    StringBuilder log = new StringBuilder();
    PTransactionId transactionId = spanChunk.getTransactionId();
    log.append(" transactionId:");
    log.append(MessageFormatUtils.debugLog(transactionId));
    log.append(" spanId:").append(spanChunk.getSpanId());
    StringBuilder spanEventSequenceLog = new StringBuilder();
    List<PSpanEvent> spanEventList = spanChunk.getSpanEventList();
    for (PSpanEvent pSpanEvent : spanEventList) {
        if (pSpanEvent == null) {
            continue;
        }
        spanEventSequenceLog.append(pSpanEvent.getSequence()).append(" ");
    }
    log.append(" spanEventSequence:").append(spanEventSequenceLog.toString());
    return log.toString();
}
Also used : PTransactionId(com.navercorp.pinpoint.grpc.trace.PTransactionId) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Example 14 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.

the class CollectorGrpcSpanFactory method buildSpanBo.

@Override
public SpanBo buildSpanBo(PSpan pSpan, Header header) {
    final SpanBo spanBo = this.grpcBinder.bindSpanBo(pSpan, header);
    final long acceptedTime = acceptedTimeService.getAcceptedTime();
    spanBo.setCollectorAcceptTime(acceptedTime);
    final List<PSpanEvent> pSpanEventList = pSpan.getSpanEventList();
    List<SpanEventBo> spanEventBos = buildSpanEventBoList(pSpanEventList);
    spanBo.addSpanEventBoList(spanEventBos);
    return spanBo;
}
Also used : PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 15 with PSpanEvent

use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method newSpanChunk.

private PSpanChunk newSpanChunk() {
    PSpanEvent event0 = newEvent(1, 1);
    PSpanEvent event1 = newEvent(2, 0);
    return newSpanChunk(event0, event1);
}
Also used : PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent)

Aggregations

PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)17 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)5 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)4 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)3 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)3 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)3 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)3 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)2 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)2 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)2 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)2 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)2 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)2 ArrayList (java.util.ArrayList)2 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 PAcceptEvent (com.navercorp.pinpoint.grpc.trace.PAcceptEvent)1 PAnnotationValue (com.navercorp.pinpoint.grpc.trace.PAnnotationValue)1