Search in sources :

Example 36 with AnnotationBo

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

the class SpanServiceImpl method transitionSqlId.

private void transitionSqlId(final List<Align> spans) {
    this.transitionAnnotation(spans, new AnnotationReplacementCallback() {

        @Override
        public void replacement(Align align, List<AnnotationBo> annotationBoList) {
            AnnotationBo sqlIdAnnotation = findAnnotation(annotationBoList, AnnotationKey.SQL_ID.getCode());
            if (sqlIdAnnotation == null) {
                return;
            }
            if (metaDataFilter != null && metaDataFilter.filter(align, MetaData.SQL)) {
                AnnotationBo annotationBo = metaDataFilter.createAnnotationBo(align, MetaData.SQL);
                annotationBoList.add(annotationBo);
                return;
            }
            // value of sqlId's annotation contains multiple values.
            final IntStringStringValue sqlValue = (IntStringStringValue) sqlIdAnnotation.getValue();
            final int sqlId = sqlValue.getIntValue();
            final String sqlParam = sqlValue.getStringValue1();
            final List<SqlMetaDataBo> sqlMetaDataList = sqlMetaDataDao.getSqlMetaData(align.getAgentId(), align.getAgentStartTime(), sqlId);
            final int size = sqlMetaDataList.size();
            if (size == 0) {
                String errorMessage = "SQL-ID not found sqlId:" + sqlId;
                AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), errorMessage);
                annotationBoList.add(api);
            } else if (size == 1) {
                final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0);
                if (StringUtils.isEmpty(sqlParam)) {
                    AnnotationBo sqlMeta = new AnnotationBo(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql());
                    annotationBoList.add(sqlMeta);
                    // AnnotationBo checkFail = checkIdentifier(spanAlign, sqlMetaDataBo);
                    // if (checkFail != null) {
                    // // fail
                    // annotationBoList.add(checkFail);
                    // return;
                    // }
                    AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(sqlMetaDataBo.getSql()));
                    annotationBoList.add(sql);
                } else {
                    logger.debug("sqlMetaDataBo:{}", sqlMetaDataBo);
                    final String outputParams = sqlParam;
                    List<String> parsedOutputParams = outputParameterParser.parseOutputParameter(outputParams);
                    logger.debug("outputPrams:{}, parsedOutputPrams:{}", outputParams, parsedOutputParams);
                    String originalSql = sqlParser.combineOutputParams(sqlMetaDataBo.getSql(), parsedOutputParams);
                    logger.debug("outputPrams{}, originalSql:{}", outputParams, originalSql);
                    AnnotationBo sqlMeta = new AnnotationBo(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql());
                    annotationBoList.add(sqlMeta);
                    AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(originalSql));
                    annotationBoList.add(sql);
                }
            } else {
                // TODO need improvement
                String collisionSqlIdCodeMessage = collisionSqlIdCodeMessage(sqlId, sqlMetaDataList);
                AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), collisionSqlIdCodeMessage);
                annotationBoList.add(api);
            }
            // add if bindValue exists
            final String bindValue = sqlValue.getStringValue2();
            if (StringUtils.isNotEmpty(bindValue)) {
                AnnotationBo bindValueAnnotation = new AnnotationBo(AnnotationKey.SQL_BINDVALUE.getCode(), bindValue);
                annotationBoList.add(bindValueAnnotation);
            }
        }
    });
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) Align(com.navercorp.pinpoint.web.calltree.span.Align) SqlMetaDataBo(com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 37 with AnnotationBo

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

the class SpanServiceImpl method transitionDynamicApiId.

private void transitionDynamicApiId(List<Align> spans) {
    this.transitionAnnotation(spans, new AnnotationReplacementCallback() {

        @Override
        public void replacement(Align align, List<AnnotationBo> annotationBoList) {
            final int apiId = align.getApiId();
            if (apiId == 0) {
                String apiString = AnnotationUtils.findApiAnnotation(annotationBoList);
                // annotation base api
                if (apiString != null) {
                    ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(align.getAgentId(), align.getStartTime(), apiId, LineNumber.NO_LINE_NUMBER, MethodTypeEnum.DEFAULT, apiString);
                    AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API_METADATA.getCode(), apiMetaDataBo);
                    annotationBoList.add(apiAnnotation);
                    return;
                }
            }
            // may be able to get a more accurate data using agentIdentifier.
            List<ApiMetaDataBo> apiMetaDataList = apiMetaDataDao.getApiMetaData(align.getAgentId(), align.getAgentStartTime(), apiId);
            int size = apiMetaDataList.size();
            if (size == 0) {
                String errorMessage = "API-DynamicID not found. api:" + apiId;
                AnnotationBo api = new AnnotationBo(AnnotationKey.ERROR_API_METADATA_NOT_FOUND.getCode(), errorMessage);
                annotationBoList.add(api);
            } else if (size == 1) {
                ApiMetaDataBo apiMetaDataBo = apiMetaDataList.get(0);
                AnnotationBo apiMetaData = new AnnotationBo(AnnotationKey.API_METADATA.getCode(), apiMetaDataBo);
                annotationBoList.add(apiMetaData);
                if (apiMetaDataBo.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
                    String apiInfo = getApiInfo(apiMetaDataBo);
                    AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API.getCode(), apiInfo);
                    annotationBoList.add(apiAnnotation);
                } else {
                    String apiTagInfo = getApiTagInfo(apiMetaDataBo);
                    AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.API_TAG.getCode(), apiTagInfo);
                    annotationBoList.add(apiAnnotation);
                }
            } else {
                String collisionMessage = collisionApiDidMessage(apiId, apiMetaDataList);
                AnnotationBo apiAnnotation = new AnnotationBo(AnnotationKey.ERROR_API_METADATA_DID_COLLSION.getCode(), collisionMessage);
                annotationBoList.add(apiAnnotation);
            }
        }
    });
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) Align(com.navercorp.pinpoint.web.calltree.span.Align) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 38 with AnnotationBo

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

the class TransactionInfoServiceImpl method getDisplayArgument0.

private AnnotationBo getDisplayArgument0(Event event) {
    // TODO needs a more generalized implementation for Arcus
    List<AnnotationBo> list = event.getAnnotationBoList();
    if (list == null) {
        return null;
    }
    final AnnotationKeyMatcher matcher = annotationKeyMatcherService.findAnnotationKeyMatcher(event.getServiceType());
    if (matcher == null) {
        return null;
    }
    for (AnnotationBo annotation : list) {
        int key = annotation.getKey();
        if (matcher.matches(key)) {
            return annotation;
        }
    }
    return null;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AnnotationKeyMatcher(com.navercorp.pinpoint.common.trace.AnnotationKeyMatcher)

Example 39 with AnnotationBo

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

the class SpanFactory method bind.

private void bind(SpanEventBo spanEvent, TSpanEvent tSpanEvent) {
    spanEvent.setSequence(tSpanEvent.getSequence());
    spanEvent.setStartElapsed(tSpanEvent.getStartElapsed());
    spanEvent.setEndElapsed(tSpanEvent.getEndElapsed());
    spanEvent.setRpc(tSpanEvent.getRpc());
    spanEvent.setServiceType(tSpanEvent.getServiceType());
    spanEvent.setDestinationId(tSpanEvent.getDestinationId());
    spanEvent.setEndPoint(tSpanEvent.getEndPoint());
    spanEvent.setApiId(tSpanEvent.getApiId());
    if (tSpanEvent.isSetDepth()) {
        spanEvent.setDepth(tSpanEvent.getDepth());
    }
    if (tSpanEvent.isSetNextSpanId()) {
        spanEvent.setNextSpanId(tSpanEvent.getNextSpanId());
    }
    List<AnnotationBo> annotationList = buildAnnotationList(tSpanEvent.getAnnotations());
    spanEvent.setAnnotationBoList(annotationList);
    final TIntStringValue exceptionInfo = tSpanEvent.getExceptionInfo();
    if (exceptionInfo != null) {
        spanEvent.setExceptionInfo(exceptionInfo.getIntValue(), exceptionInfo.getStringValue());
    }
    if (tSpanEvent.isSetNextAsyncId()) {
        spanEvent.setNextAsyncId(tSpanEvent.getNextAsyncId());
    }
// async id
// if (localAsyncId == null) {
// if (tSpanEvent.isSetAsyncId()) {
// spanEvent.setAsyncId(tSpanEvent.getAsyncId());
// }
// if (tSpanEvent.isSetAsyncSequence()) {
// spanEvent.setAsyncSequence(tSpanEvent.getAsyncSequence());
// }
// } else {
// spanEvent.setAsyncId(localAsyncId.getAsyncId());
// spanEvent.setAsyncSequence((short) localAsyncId.getSequence());
// }
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 40 with AnnotationBo

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

the class SpanFactory method buildAnnotationList.

private List<AnnotationBo> buildAnnotationList(List<TAnnotation> tAnnotationList) {
    if (tAnnotationList == null) {
        return new ArrayList<>();
    }
    List<AnnotationBo> boList = new ArrayList<>(tAnnotationList.size());
    for (TAnnotation tAnnotation : tAnnotationList) {
        final AnnotationBo annotationBo = newAnnotationBo(tAnnotation);
        boList.add(annotationBo);
    }
    boList.sort(AnnotationComparator.INSTANCE);
    return boList;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation)

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