Search in sources :

Example 31 with SpanEventBo

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

the class TraceService method insertSpanChunk.

public void insertSpanChunk(final SpanChunkBo spanChunkBo) {
    traceDao.insertSpanChunk(spanChunkBo);
    final ServiceType applicationServiceType = getApplicationServiceType(spanChunkBo);
    final List<SpanEventBo> spanEventList = spanChunkBo.getSpanEventBoList();
    if (spanEventList != null) {
        // TODO need to batch update later.
        insertSpanEventList(spanEventList, applicationServiceType, spanChunkBo.getApplicationId(), spanChunkBo.getAgentId(), spanChunkBo.getEndPoint());
    }
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 32 with SpanEventBo

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

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

the class SpanDecoderV0 method readSpanValue.

public void readSpanValue(Buffer buffer, SpanBo span, SpanDecodingContext decodingContext) {
    final byte version = buffer.readByte();
    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, decodingContext, SEQUENCE_SPAN_EVENT_FILTER);
    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 34 with SpanEventBo

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

the class CollectorGrpcSpanFactory method buildSpanChunkBo.

@Override
public SpanChunkBo buildSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
    final SpanChunkBo spanChunkBo = this.grpcBinder.bindSpanChunkBo(pSpanChunk, header);
    final long acceptedTime = acceptedTimeService.getAcceptedTime();
    spanChunkBo.setCollectorAcceptTime(acceptedTime);
    final List<PSpanEvent> pSpanEventList = pSpanChunk.getSpanEventList();
    List<SpanEventBo> spanEventList = buildSpanEventBoList(pSpanEventList);
    spanChunkBo.addSpanEventBoList(spanEventList);
    return spanChunkBo;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanEvent(com.navercorp.pinpoint.grpc.trace.PSpanEvent) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 35 with SpanEventBo

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

the class GrpcSpanBinder method buildSpanEventBo.

// for test
public SpanEventBo buildSpanEventBo(PSpanEvent pSpanEvent, SpanEventBo prevSpanEvent) {
    Objects.requireNonNull(pSpanEvent, "pSpanEvent");
    final SpanEventBo spanEvent = new SpanEventBo();
    bind(spanEvent, pSpanEvent, prevSpanEvent);
    return spanEvent;
}
Also used : 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