Search in sources :

Example 1 with SpanEventBitField

use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField in project pinpoint by naver.

the class SpanDecoderV0 method readNextSpanEvent.

private SpanEventBo readNextSpanEvent(final Buffer buffer, final SpanEventBo prev, SpanDecodingContext decodingContext) {
    final SpanEventBo spanEventBo = new SpanEventBo();
    final SpanEventBitField bitField = new SpanEventBitField(buffer.readShort());
    switch(bitField.getStartElapsedEncodingStrategy()) {
        case PREV_DELTA:
            int startTimeDelta = buffer.readVInt();
            int startTime = startTimeDelta + prev.getStartElapsed();
            spanEventBo.setStartElapsed(startTime);
            break;
        case PREV_EQUALS:
            spanEventBo.setStartElapsed(prev.getStartElapsed());
            break;
        default:
            throw new IllegalStateException("unsupported SequenceEncodingStrategy");
    }
    spanEventBo.setEndElapsed(buffer.readVInt());
    switch(bitField.getSequenceEncodingStrategy()) {
        case PREV_DELTA:
            int sequenceDelta = buffer.readVInt();
            final int sequence = sequenceDelta + prev.getSequence();
            spanEventBo.setSequence((short) sequence);
            break;
        case PREV_ADD1:
            spanEventBo.setSequence((short) (prev.getSequence() + 1));
            break;
        default:
            throw new IllegalStateException("unsupported SequenceEncodingStrategy");
    }
    switch(bitField.getDepthEncodingStrategy()) {
        case RAW:
            spanEventBo.setDepth(buffer.readSVInt());
            break;
        case PREV_EQUALS:
            spanEventBo.setDepth(prev.getDepth());
            break;
        default:
            throw new IllegalStateException("unsupported DepthEncodingStrategy");
    }
    switch(bitField.getServiceTypeEncodingStrategy()) {
        case RAW:
            spanEventBo.setServiceType(buffer.readShort());
            break;
        case PREV_EQUALS:
            spanEventBo.setServiceType(prev.getServiceType());
            break;
        default:
            throw new IllegalStateException("unsupported ServiceTypeEncodingStrategy");
    }
    spanEventBo.setApiId(buffer.readSVInt());
    if (bitField.isSetRpc()) {
        spanEventBo.setRpc(buffer.readPrefixedString());
    }
    if (bitField.isSetEndPoint()) {
        spanEventBo.setEndPoint(buffer.readPrefixedString());
    }
    if (bitField.isSetDestinationId()) {
        spanEventBo.setDestinationId(buffer.readPrefixedString());
    }
    if (bitField.isSetNextSpanId()) {
        spanEventBo.setNextSpanId(buffer.readLong());
    }
    if (bitField.isSetHasException()) {
        int exceptionId = buffer.readSVInt();
        String exceptionMessage = buffer.readPrefixedString();
        spanEventBo.setExceptionInfo(exceptionId, exceptionMessage);
    }
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = readAnnotationList(buffer, decodingContext);
        spanEventBo.setAnnotationBoList(annotationBoList);
    }
    if (bitField.isSetNextAsyncId()) {
        spanEventBo.setNextAsyncId(buffer.readSVInt());
    }
    if (bitField.isSetAsyncId()) {
        spanEventBo.setAsyncId(buffer.readInt());
        spanEventBo.setAsyncSequence((short) buffer.readVInt());
    }
    return spanEventBo;
}
Also used : SpanEventBitField(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 2 with SpanEventBitField

use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField in project pinpoint by naver.

the class SpanDecoderV0 method readFirstSpanEvent.

private SpanEventBo readFirstSpanEvent(Buffer buffer, SpanEventBo firstSpanEvent, SpanDecodingContext decodingContext) {
    SpanEventBitField bitField = new SpanEventBitField(buffer.readByte());
    firstSpanEvent.setStartElapsed(buffer.readVInt());
    firstSpanEvent.setEndElapsed(buffer.readVInt());
    firstSpanEvent.setSequence(buffer.readShort());
    firstSpanEvent.setDepth(buffer.readSVInt());
    firstSpanEvent.setServiceType(buffer.readShort());
    if (bitField.isSetRpc()) {
        firstSpanEvent.setRpc(buffer.readPrefixedString());
    }
    if (bitField.isSetEndPoint()) {
        firstSpanEvent.setEndPoint(buffer.readPrefixedString());
    }
    if (bitField.isSetDestinationId()) {
        firstSpanEvent.setDestinationId(buffer.readPrefixedString());
    }
    firstSpanEvent.setApiId(buffer.readSVInt());
    if (bitField.isSetNextSpanId()) {
        firstSpanEvent.setNextSpanId(buffer.readLong());
    }
    if (bitField.isSetHasException()) {
        int exceptionId = buffer.readSVInt();
        String exceptionMessage = buffer.readPrefixedString();
        firstSpanEvent.setExceptionInfo(exceptionId, exceptionMessage);
    }
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = readAnnotationList(buffer, decodingContext);
        firstSpanEvent.setAnnotationBoList(annotationBoList);
    }
    if (bitField.isSetNextAsyncId()) {
        firstSpanEvent.setNextAsyncId(buffer.readSVInt());
    }
    //        }
    return firstSpanEvent;
}
Also used : SpanEventBitField(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 3 with SpanEventBitField

use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField in project pinpoint by naver.

the class SpanEncoderV0 method writeFirstSpanEvent.

public void writeFirstSpanEvent(Buffer buffer, SpanEventBo spanEventBo, SpanEncodingContext<?> encodingContext) {
    final SpanEventBitField bitField = SpanEventBitField.buildFirst(spanEventBo);
    final byte firstSpanBitField1 = (byte) bitField.getBitField();
    buffer.putByte(firstSpanBitField1);
    buffer.putVInt(spanEventBo.getStartElapsed());
    buffer.putVInt(spanEventBo.getEndElapsed());
    buffer.putShort(spanEventBo.getSequence());
    buffer.putSVInt(spanEventBo.getDepth());
    buffer.putShort(spanEventBo.getServiceType());
    if (bitField.isSetRpc()) {
        buffer.putPrefixedString(spanEventBo.getRpc());
    }
    if (bitField.isSetEndPoint()) {
        buffer.putPrefixedString(spanEventBo.getEndPoint());
    }
    if (bitField.isSetDestinationId()) {
        buffer.putPrefixedString(spanEventBo.getDestinationId());
    }
    buffer.putSVInt(spanEventBo.getApiId());
    if (bitField.isSetNextSpanId()) {
        buffer.putLong(spanEventBo.getNextSpanId());
    }
    if (bitField.isSetHasException()) {
        buffer.putSVInt(spanEventBo.getExceptionId());
        buffer.putPrefixedString(spanEventBo.getExceptionMessage());
    }
    if (bitField.isSetAnnotation()) {
        final List<AnnotationBo> annotationBoList = spanEventBo.getAnnotationBoList();
        writeAnnotationList(buffer, annotationBoList, encodingContext);
    }
    if (bitField.isSetNextAsyncId()) {
        buffer.putSVInt(spanEventBo.getNextAsyncId());
    }
//        if (bitField.isSetAsyncId()) {
//            buffer.putInt(spanEventBo.getAsyncId());
//            buffer.putVInt(spanEventBo.getAsyncSequence());
//        }
}
Also used : SpanEventBitField(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 4 with SpanEventBitField

use of com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField in project pinpoint by naver.

the class SpanEncoderV0 method writeNextSpanEvent.

public void writeNextSpanEvent(Buffer buffer, SpanEventBo spanEventBo, SpanEventBo prevSpanEvent, SpanEncodingContext<?> encodingContext) {
    final SpanEventBitField bitField = SpanEventBitField.build(spanEventBo, prevSpanEvent);
    buffer.putShort(bitField.getBitField());
    switch(bitField.getStartElapsedEncodingStrategy()) {
        case PREV_DELTA:
            final int startTimeDelta = spanEventBo.getStartElapsed() - prevSpanEvent.getStartElapsed();
            buffer.putVInt(startTimeDelta);
            break;
        case PREV_EQUALS:
            // skip bitfield
            break;
        default:
            throw new IllegalStateException("unsupported StartElapsedEncodingStrategy");
    }
    buffer.putVInt(spanEventBo.getEndElapsed());
    switch(bitField.getSequenceEncodingStrategy()) {
        case PREV_DELTA:
            final int sequenceDelta = spanEventBo.getSequence() - prevSpanEvent.getSequence();
            buffer.putVInt(sequenceDelta);
            break;
        case PREV_ADD1:
            // skip bitfield
            break;
        default:
            throw new IllegalStateException("unsupported SequenceEncodingStrategy");
    }
    switch(bitField.getDepthEncodingStrategy()) {
        case RAW:
            buffer.putSVInt(spanEventBo.getDepth());
            break;
        case PREV_EQUALS:
            // skip bitfield
            break;
        default:
            throw new IllegalStateException("unsupported DepthEncodingStrategy");
    }
    switch(bitField.getServiceTypeEncodingStrategy()) {
        case RAW:
            buffer.putShort(spanEventBo.getServiceType());
            break;
        case PREV_EQUALS:
            // skip bitfield
            break;
        default:
            throw new IllegalStateException("unsupported ServiceTypeEncodingStrategy");
    }
    buffer.putSVInt(spanEventBo.getApiId());
    if (bitField.isSetRpc()) {
        buffer.putPrefixedString(spanEventBo.getRpc());
    }
    if (bitField.isSetEndPoint()) {
        buffer.putPrefixedString(spanEventBo.getEndPoint());
    }
    if (bitField.isSetDestinationId()) {
        buffer.putPrefixedString(spanEventBo.getDestinationId());
    }
    if (bitField.isSetNextSpanId()) {
        buffer.putLong(spanEventBo.getNextSpanId());
    }
    if (bitField.isSetHasException()) {
        buffer.putSVInt(spanEventBo.getExceptionId());
        buffer.putPrefixedString(spanEventBo.getExceptionMessage());
    }
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = spanEventBo.getAnnotationBoList();
        writeAnnotationList(buffer, annotationBoList, encodingContext);
    }
    if (bitField.isSetNextAsyncId()) {
        buffer.putSVInt(spanEventBo.getNextAsyncId());
    }
    if (bitField.isSetAsyncId()) {
        buffer.putInt(spanEventBo.getAsyncId());
        buffer.putVInt(spanEventBo.getAsyncSequence());
    }
}
Also used : SpanEventBitField(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Aggregations

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)4 SpanEventBitField (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField)4 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)1