Search in sources :

Example 1 with PMessageEvent

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

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)1 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)1 PMessageEvent (com.navercorp.pinpoint.grpc.trace.PMessageEvent)1 PNextEvent (com.navercorp.pinpoint.grpc.trace.PNextEvent)1