Search in sources :

Example 1 with PNextEvent

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

the class GrpcSpanMessageConverter method buildPSpanEvent.

@VisibleForTesting
public PSpanEvent.Builder buildPSpanEvent(SpanEvent spanEvent) {
    final PSpanEvent.Builder pSpanEvent = getSpanEventBuilder();
    // tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
    if (spanEvent.getElapsedTime() != 0) {
        pSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
    }
    pSpanEvent.setSequence(spanEvent.getSequence());
    // tSpanEvent.setRpc(spanEvent.getRpc());
    pSpanEvent.setServiceType(spanEvent.getServiceType());
    // tSpanEvent.setAnnotations();
    if (spanEvent.getDepth() != -1) {
        pSpanEvent.setDepth(spanEvent.getDepth());
    }
    pSpanEvent.setApiId(spanEvent.getApiId());
    final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
        PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
        pSpanEvent.setExceptionInfo(pIntStringValue);
    }
    final PNextEvent nextEvent = buildNextEvent(spanEvent);
    if (nextEvent != null) {
        pSpanEvent.setNextEvent(nextEvent);
    }
    final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
    if (asyncIdObject != null) {
        pSpanEvent.setAsyncEvent(asyncIdObject.getAsyncId());
    }
    final List<Annotation<?>> annotations = spanEvent.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<PAnnotation> pAnnotations = buildPAnnotation(annotations);
        pSpanEvent.addAllAnnotation(pAnnotations);
    }
    return pSpanEvent;
}
Also used : PNextEvent(com.navercorp.pinpoint.grpc.trace.PNextEvent) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue) PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) AsyncId(com.navercorp.pinpoint.profiler.context.AsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) PAnnotation(com.navercorp.pinpoint.grpc.trace.PAnnotation) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 2 with PNextEvent

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

the class GrpcSpanBinder method bind.

private void bind(SpanEventBo spanEvent, PSpanEvent pSpanEvent, SpanEventBo prevSpanEvent) {
    spanEvent.setSequence((short) pSpanEvent.getSequence());
    if (prevSpanEvent == null) {
        int startElapsed = pSpanEvent.getStartElapsed();
        spanEvent.setStartElapsed(startElapsed);
    } else {
        int startElapsed = pSpanEvent.getStartElapsed() + prevSpanEvent.getStartElapsed();
        spanEvent.setStartElapsed(startElapsed);
    }
    spanEvent.setEndElapsed(pSpanEvent.getEndElapsed());
    spanEvent.setServiceType((short) pSpanEvent.getServiceType());
    spanEvent.setApiId(pSpanEvent.getApiId());
    // v2 spec
    final int depth = pSpanEvent.getDepth();
    if (depth == 0) {
        // depth compact case
        if (prevSpanEvent == null) {
            // first spanEvent
            spanEvent.setDepth(0);
        } else {
            spanEvent.setDepth(prevSpanEvent.getDepth());
        }
    } else {
        spanEvent.setDepth(depth);
    }
    if (pSpanEvent.hasNextEvent()) {
        final PNextEvent nextEvent = pSpanEvent.getNextEvent();
        final PNextEvent.FieldCase fieldCase = nextEvent.getFieldCase();
        if (fieldCase == PNextEvent.FieldCase.MESSAGEEVENT) {
            final PMessageEvent messageEvent = nextEvent.getMessageEvent();
            spanEvent.setNextSpanId(messageEvent.getNextSpanId());
            final String destinationId = messageEvent.getDestinationId();
            if (StringUtils.hasLength(destinationId)) {
                spanEvent.setDestinationId(destinationId);
            }
            final String endPoint = messageEvent.getEndPoint();
            if (StringUtils.hasLength(endPoint)) {
                spanEvent.setEndPoint(endPoint);
            }
        } else {
            logger.info("unknown nextEvent:{}", nextEvent);
        }
    }
    final int asyncEvent = pSpanEvent.getAsyncEvent();
    spanEvent.setNextAsyncId(asyncEvent);
    List<AnnotationBo> annotationList = buildAnnotationList(pSpanEvent.getAnnotationList());
    spanEvent.setAnnotationBoList(annotationList);
    if (pSpanEvent.hasExceptionInfo()) {
        final PIntStringValue exceptionInfo = pSpanEvent.getExceptionInfo();
        spanEvent.setExceptionInfo(exceptionInfo.getIntValue(), getExceptionMessage(exceptionInfo));
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) PNextEvent(com.navercorp.pinpoint.grpc.trace.PNextEvent) PMessageEvent(com.navercorp.pinpoint.grpc.trace.PMessageEvent) PIntStringValue(com.navercorp.pinpoint.grpc.trace.PIntStringValue)

Aggregations

PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PNextEvent (com.navercorp.pinpoint.grpc.trace.PNextEvent)2 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)1 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)1 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)1 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 PMessageEvent (com.navercorp.pinpoint.grpc.trace.PMessageEvent)1 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)1 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)1 AsyncId (com.navercorp.pinpoint.profiler.context.AsyncId)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1