Search in sources :

Example 11 with AnnotationBo

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

the class SpanFactory method newSpanBo.

// for test
SpanBo newSpanBo(TSpan tSpan) {
    final SpanBo spanBo = new SpanBo();
    spanBo.setAgentId(tSpan.getAgentId());
    spanBo.setApplicationId(tSpan.getApplicationName());
    spanBo.setAgentStartTime(tSpan.getAgentStartTime());
    final TransactionId transactionId = newTransactionId(tSpan.getTransactionId(), spanBo.getAgentId());
    spanBo.setTransactionId(transactionId);
    spanBo.setSpanId(tSpan.getSpanId());
    spanBo.setParentSpanId(tSpan.getParentSpanId());
    spanBo.setStartTime(tSpan.getStartTime());
    spanBo.setElapsed(tSpan.getElapsed());
    spanBo.setRpc(tSpan.getRpc());
    spanBo.setServiceType(tSpan.getServiceType());
    spanBo.setEndPoint(tSpan.getEndPoint());
    spanBo.setFlag(tSpan.getFlag());
    spanBo.setApiId(tSpan.getApiId());
    spanBo.setErrCode(tSpan.getErr());
    spanBo.setAcceptorHost(tSpan.getAcceptorHost());
    spanBo.setRemoteAddr(tSpan.getRemoteAddr());
    spanBo.setLoggingTransactionInfo(tSpan.getLoggingTransactionInfo());
    // applicationServiceType is not saved for older versions where applicationServiceType does not exist.
    if (tSpan.isSetApplicationServiceType()) {
        spanBo.setApplicationServiceType(tSpan.getApplicationServiceType());
    } else {
        spanBo.setApplicationServiceType(tSpan.getServiceType());
    }
    spanBo.setParentApplicationId(tSpan.getParentApplicationName());
    spanBo.setParentApplicationServiceType(tSpan.getParentApplicationType());
    // FIXME span.errCode contains error of span and spanEvent
    // because exceptionInfo is the error information of span itself, exceptionInfo can be null even if errCode is not 0
    final TIntStringValue exceptionInfo = tSpan.getExceptionInfo();
    if (exceptionInfo != null) {
        spanBo.setExceptionInfo(exceptionInfo.getIntValue(), exceptionInfo.getStringValue());
    }
    List<AnnotationBo> annotationBoList = buildAnnotationList(tSpan.getAnnotations());
    spanBo.setAnnotationBoList(annotationBoList);
    return spanBo;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId)

Example 12 with AnnotationBo

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

the class SpanEncoderV0 method writeAnnotationList.

private void writeAnnotationList(Buffer buffer, List<AnnotationBo> annotationBoList, SpanEncodingContext<?> encodingContext) {
    if (CollectionUtils.isEmpty(annotationBoList)) {
        return;
    }
    buffer.putVInt(annotationBoList.size());
    // AnnotationBo prev = encodingCtx.getPrevFirstAnnotationBo();
    AnnotationBo prev = null;
    for (int i = 0; i < annotationBoList.size(); i++) {
        final AnnotationBo current = annotationBoList.get(i);
        // first row
        if (i == 0) {
            // first annotation
            buffer.putSVInt(current.getKey());
            Object value = current.getValue();
            byte valueTypeCode = transcoder.getTypeCode(value);
            byte[] valueBytes = transcoder.encode(value, valueTypeCode);
            buffer.putByte(valueTypeCode);
            buffer.putPrefixedBytes(valueBytes);
        // else {
        // writeDeltaAnnotationBo(buffer, prev, current);
        // }
        // save first annotation
        // encodingCtx.setPrevFirstAnnotationBo(current);
        } else {
            writeDeltaAnnotationBo(buffer, prev, current);
        }
        prev = current;
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 13 with AnnotationBo

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

the class RecordFactory method getDisplayArgument.

private String getDisplayArgument(Align align) {
    final AnnotationBo displayArgument = getDisplayArgument0(align.getServiceType(), align.getAnnotationBoList());
    if (displayArgument == null) {
        return "";
    }
    final AnnotationKey key = findAnnotationKey(displayArgument.getKey());
    return this.annotationRecordFormatter.formatArguments(key, displayArgument, align);
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey)

Example 14 with AnnotationBo

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

the class RecordFactory method getApi.

private Api getApi(final Align align) {
    final AnnotationBo annotation = AnnotationUtils.findAnnotationBo(align.getAnnotationBoList(), AnnotationKey.API_METADATA);
    if (annotation != null) {
        final ApiMetaDataBo apiMetaData = (ApiMetaDataBo) annotation.getValue();
        String apiInfo = apiMetaData.getDescription();
        if (apiMetaData.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
            ApiParser parser = apiParserProvider.getParser();
            return parser.parse(apiMetaData);
        }
        // parse error
        return new Api(apiInfo, "", apiInfo, apiMetaData.getMethodTypeEnum());
    } else {
        AnnotationKey apiMetaDataError = getApiMetaDataError(align.getAnnotationBoList());
        return new Api(apiMetaDataError.getName(), "", "", MethodTypeEnum.DEFAULT);
    }
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) ApiParser(com.navercorp.pinpoint.common.server.trace.ApiParser) Api(com.navercorp.pinpoint.common.server.trace.Api)

Example 15 with AnnotationBo

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

Aggregations

AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)55 ArrayList (java.util.ArrayList)17 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)13 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)7 Test (org.junit.Test)7 List (java.util.List)6 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)5 SpanEventBitField (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanEventBitField)5 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)5 Align (com.navercorp.pinpoint.web.calltree.span.Align)4 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)4 ByteBuffer (java.nio.ByteBuffer)4 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)3 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)3 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 SqlMetaDataBo (com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)2 StringMetaDataBo (com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)2