Search in sources :

Example 1 with SpanBitFiled

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

the class SpanDecoderV0 method readSpanValue.

public void readSpanValue(Buffer buffer, SpanBo span, SpanEventBo firstSpanEvent, SpanDecodingContext decodingContext) {
    final byte version = buffer.readByte();
    if (version != 0) {
        throw new IllegalStateException("unknown version :" + version);
    }
    span.setVersion(version);
    final SpanBitFiled bitFiled = new SpanBitFiled(buffer.readByte());
    final short serviceType = buffer.readShort();
    span.setServiceType(serviceType);
    switch(bitFiled.getApplicationServiceTypeEncodingStrategy()) {
        case PREV_EQUALS:
            span.setApplicationServiceType(serviceType);
            break;
        case RAW:
            span.setApplicationServiceType(buffer.readShort());
            break;
        default:
            throw new IllegalStateException("applicationServiceType");
    }
    if (!bitFiled.isRoot()) {
        span.setParentSpanId(buffer.readLong());
    } else {
        span.setParentSpanId(-1);
    }
    final long startTimeDelta = buffer.readVLong();
    final long startTime = span.getCollectorAcceptTime() - startTimeDelta;
    span.setStartTime(startTime);
    span.setElapsed(buffer.readVInt());
    span.setRpc(buffer.readPrefixedString());
    span.setEndPoint(buffer.readPrefixedString());
    span.setRemoteAddr(buffer.readPrefixedString());
    span.setApiId(buffer.readSVInt());
    if (bitFiled.isSetErrorCode()) {
        span.setErrCode(buffer.readInt());
    }
    if (bitFiled.isSetHasException()) {
        int exceptionId = buffer.readSVInt();
        String exceptionMessage = buffer.readPrefixedString();
        span.setExceptionInfo(exceptionId, exceptionMessage);
    }
    if (bitFiled.isSetFlag()) {
        span.setFlag(buffer.readShort());
    }
    if (bitFiled.isSetLoggingTransactionInfo()) {
        span.setLoggingTransactionInfo(buffer.readByte());
    }
    span.setAcceptorHost(buffer.readPrefixedString());
    if (bitFiled.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = readAnnotationList(buffer, decodingContext);
        span.setAnnotationBoList(annotationBoList);
    }
    List<SpanEventBo> spanEventBoList = readSpanEvent(buffer, firstSpanEvent, decodingContext);
    span.addSpanEventBoList(spanEventBoList);
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanBitFiled(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 2 with SpanBitFiled

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

the class SpanEncoderV0 method encodeSpanColumnValue.

@Override
public ByteBuffer encodeSpanColumnValue(SpanEncodingContext<SpanBo> encodingContext) {
    final SpanBo span = encodingContext.getValue();
    final SpanBitFiled bitField = SpanBitFiled.build(span);
    final Buffer buffer = new AutomaticBuffer(256);
    final byte version = span.getRawVersion();
    buffer.putByte(version);
    // bit field
    buffer.putByte(bitField.getBitField());
    final short serviceType = span.getServiceType();
    buffer.putShort(serviceType);
    switch(bitField.getApplicationServiceTypeEncodingStrategy()) {
        case PREV_EQUALS:
            break;
        case RAW:
            buffer.putShort(span.getApplicationServiceType());
            break;
        default:
            throw new IllegalStateException("applicationServiceType");
    }
    // buffer.put(spanID);
    if (!bitField.isRoot()) {
        buffer.putLong(span.getParentSpanId());
    }
    // prevSpanEvent coding
    final long startTime = span.getStartTime();
    final long startTimeDelta = span.getCollectorAcceptTime() - startTime;
    buffer.putVLong(startTimeDelta);
    buffer.putVInt(span.getElapsed());
    buffer.putPrefixedString(span.getRpc());
    buffer.putPrefixedString(span.getEndPoint());
    buffer.putPrefixedString(span.getRemoteAddr());
    buffer.putSVInt(span.getApiId());
    // BIT flag
    if (bitField.isSetErrorCode()) {
        buffer.putInt(span.getErrCode());
    }
    if (bitField.isSetHasException()) {
        buffer.putSVInt(span.getExceptionId());
        buffer.putPrefixedString(span.getExceptionMessage());
    }
    if (bitField.isSetFlag()) {
        buffer.putShort(span.getFlag());
    }
    if (bitField.isSetLoggingTransactionInfo()) {
        buffer.putByte(span.getLoggingTransactionInfo());
    }
    buffer.putPrefixedString(span.getAcceptorHost());
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = span.getAnnotationBoList();
        writeAnnotationList(buffer, annotationBoList, encodingContext);
    }
    final List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
    writeSpanEventList(buffer, spanEventBoList, encodingContext);
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) SpanBitFiled(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)2 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)2 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 ByteBuffer (java.nio.ByteBuffer)1