Search in sources :

Example 66 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class SpanEncoderV0 method writeSpanEventList.

private void writeSpanEventList(Buffer buffer, List<SpanEventBo> spanEventBoList, SpanEncodingContext<?> encodingContext) {
    if (CollectionUtils.isEmpty(spanEventBoList)) {
        buffer.putVInt(0);
    } else {
        buffer.putVInt(spanEventBoList.size());
        SpanEventBo prevSpanEvent = null;
        for (SpanEventBo spanEventBo : spanEventBoList) {
            if (prevSpanEvent == null) {
                writeFirstSpanEvent(buffer, spanEventBo, encodingContext);
            } else {
                writeNextSpanEvent(buffer, spanEventBo, prevSpanEvent, encodingContext);
            }
            prevSpanEvent = spanEventBo;
        }
    }
}
Also used : SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 67 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo 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)

Example 68 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class SpanEncoderV0 method encodeSpanQualifier.

@Override
public ByteBuffer encodeSpanQualifier(SpanEncodingContext<SpanBo> encodingContext) {
    final SpanBo spanBo = encodingContext.getValue();
    final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
    final SpanEventBo firstEvent = getFirstSpanEvent(spanEventBoList);
    return encodeQualifier(TYPE_SPAN, spanBo, firstEvent, null);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 69 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class SpanDecoderV0 method readSpanEvent.

private List<SpanEventBo> readSpanEvent(Buffer buffer, SpanDecodingContext decodingContext, SpanEventFilter spanEventFilter) {
    final int spanEventSize = buffer.readVInt();
    if (spanEventSize <= 0) {
        return new ArrayList<>();
    }
    final List<SpanEventBo> spanEventBoList = new ArrayList<>();
    SpanEventBo prev = null;
    for (int i = 0; i < spanEventSize; i++) {
        SpanEventBo spanEvent;
        if (i == 0) {
            spanEvent = readFirstSpanEvent(buffer, decodingContext);
        } else {
            spanEvent = readNextSpanEvent(buffer, prev, decodingContext);
        }
        prev = spanEvent;
        boolean accept = spanEventFilter.filter(spanEvent);
        if (accept) {
            spanEventBoList.add(spanEvent);
        }
    }
    return spanEventBoList;
}
Also used : ArrayList(java.util.ArrayList) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 70 with SpanEventBo

use of com.navercorp.pinpoint.common.server.bo.SpanEventBo in project pinpoint by naver.

the class SpanDecoderV0 method readFirstSpanEvent.

private SpanEventBo readFirstSpanEvent(Buffer buffer, SpanDecodingContext decodingContext) {
    final SpanEventBitField bitField = new SpanEventBitField(buffer.readByte());
    final SpanEventBo firstSpanEvent = new SpanEventBo();
    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) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)94 Test (org.junit.Test)39 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)26 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)14 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)13 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)11 ArrayList (java.util.ArrayList)11 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)9 ByteBuffer (java.nio.ByteBuffer)8 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)4 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)4 Header (com.navercorp.pinpoint.grpc.Header)4 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)4 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)4 SpanAcceptor (com.navercorp.pinpoint.web.filter.visitor.SpanAcceptor)4 SpanEventVisitor (com.navercorp.pinpoint.web.filter.visitor.SpanEventVisitor)4 SpanReader (com.navercorp.pinpoint.web.filter.visitor.SpanReader)4 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)3 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)3 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)3