Search in sources :

Example 1 with AnnotationBo

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

the class AnnotationBoDecoderTest method testWriteValue.

@Test
public void testWriteValue() throws Exception {
    final AnnotationBo annotation = new AnnotationBo();
    annotation.setKey(AnnotationKey.API.getCode());
    final String value = RandomStringUtils.random(RandomUtils.nextInt(0, 20));
    annotation.setValue(value);
    final Buffer buffer = new AutomaticBuffer(128);
    this.serializer.writeAnnotationList(Lists.newArrayList(annotation), buffer);
    buffer.setOffset(0);
    List<AnnotationBo> decode = annotationBoDecoder.decode(buffer);
    Assert.assertEquals(decode.size(), 1);
    AnnotationBo decodedAnnotation = decode.get(0);
    Assert.assertEquals(annotation.getKey(), decodedAnnotation.getKey());
    Assert.assertEquals(annotation.getValue(), decodedAnnotation.getValue());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 2 with AnnotationBo

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

the class RecordFactory method getAnnotations.

public List<Record> getAnnotations(final int depth, final int parentId, SpanAlign align) {
    List<Record> list = new ArrayList<>();
    for (AnnotationBo annotation : align.getAnnotationBoList()) {
        final AnnotationKey key = findAnnotationKey(annotation.getKey());
        if (key.isViewInRecordSet()) {
            final Record record = new Record(depth, getNextId(), parentId, false, key.getName(), annotation.getValue().toString(), 0L, 0L, 0, null, null, null, null, false, false, null, 0, 0, MethodTypeEnum.DEFAULT, annotation.isAuthorized());
            list.add(record);
        }
    }
    return list;
}
Also used : AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) AnnotationKey(com.navercorp.pinpoint.common.trace.AnnotationKey)

Example 3 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 SpanAlign align) {
    final AnnotationBo annotation = AnnotationUtils.findAnnotationBo(align.getAnnotationBoList(), AnnotationKey.API_METADATA);
    if (annotation != null) {
        final Api api = new Api();
        final ApiMetaDataBo apiMetaData = (ApiMetaDataBo) annotation.getValue();
        String apiInfo = getApiInfo(apiMetaData);
        api.setTitle(apiInfo);
        api.setDescription(apiInfo);
        if (apiMetaData.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
            try {
                ApiDescription apiDescription = apiDescriptionParser.parse(api.description);
                api.setTitle(apiDescription.getSimpleMethodDescription());
                api.setClassName(apiDescription.getSimpleClassName());
            } catch (Exception e) {
                logger.debug("Failed to api parse. {}", api.description, e);
            }
        }
        api.setMethodTypeEnum(apiMetaData.getMethodTypeEnum());
        return api;
    } else {
        final Api api = new Api();
        AnnotationKey apiMetaDataError = getApiMetaDataError(align.getAnnotationBoList());
        api.setTitle(apiMetaDataError.getName());
        return api;
    }
}
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) ApiDescription(com.navercorp.pinpoint.common.util.ApiDescription)

Example 4 with AnnotationBo

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

the class SpanServiceImpl method transitionAnnotation.

private void transitionAnnotation(List<SpanAlign> spans, AnnotationReplacementCallback annotationReplacementCallback) {
    for (SpanAlign spanAlign : spans) {
        List<AnnotationBo> annotationBoList = spanAlign.getAnnotationBoList();
        if (annotationBoList == null) {
            annotationBoList = new ArrayList<>();
            spanAlign.setAnnotationBoList(annotationBoList);
        }
        annotationReplacementCallback.replacement(spanAlign, annotationBoList);
    }
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo)

Example 5 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<SpanAlign> spans) {
    this.transitionAnnotation(spans, new AnnotationReplacementCallback() {

        @Override
        public void replacement(SpanAlign spanAlign, List<AnnotationBo> annotationBoList) {
            AnnotationBo sqlIdAnnotation = findAnnotation(annotationBoList, AnnotationKey.SQL_ID.getCode());
            if (sqlIdAnnotation == null) {
                return;
            }
            if (metaDataFilter != null && metaDataFilter.filter(spanAlign, MetaData.SQL)) {
                AnnotationBo annotationBo = metaDataFilter.createAnnotationBo(spanAlign, 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(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), sqlId);
            final int size = sqlMetaDataList.size();
            if (size == 0) {
                AnnotationBo api = new AnnotationBo();
                api.setKey(AnnotationKey.SQL.getCode());
                api.setValue("SQL-ID not found sqlId:" + sqlId);
                annotationBoList.add(api);
            } else if (size == 1) {
                final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0);
                if (StringUtils.isEmpty(sqlParam)) {
                    AnnotationBo sqlMeta = new AnnotationBo();
                    sqlMeta.setKey(AnnotationKey.SQL_METADATA.getCode());
                    sqlMeta.setValue(sqlMetaDataBo.getSql());
                    annotationBoList.add(sqlMeta);
                    //                        AnnotationBo checkFail = checkIdentifier(spanAlign, sqlMetaDataBo);
                    //                        if (checkFail != null) {
                    //                            // fail
                    //                            annotationBoList.add(checkFail);
                    //                            return;
                    //                        }
                    AnnotationBo sql = new AnnotationBo();
                    sql.setKey(AnnotationKey.SQL.getCode());
                    sql.setValue(sqlMetaDataBo.getSql().trim());
                    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();
                    sqlMeta.setKey(AnnotationKey.SQL_METADATA.getCode());
                    sqlMeta.setValue(sqlMetaDataBo.getSql());
                    annotationBoList.add(sqlMeta);
                    AnnotationBo sql = new AnnotationBo();
                    sql.setKey(AnnotationKey.SQL.getCode());
                    sql.setValue(originalSql.trim());
                    annotationBoList.add(sql);
                }
            } else {
                // TODO need improvement
                AnnotationBo api = new AnnotationBo();
                api.setKey(AnnotationKey.SQL.getCode());
                api.setValue(collisionSqlIdCodeMessage(sqlId, sqlMetaDataList));
                annotationBoList.add(api);
            }
            // add if bindValue exists
            final String bindValue = sqlValue.getStringValue2();
            if (StringUtils.isNotEmpty(bindValue)) {
                AnnotationBo bindValueAnnotation = new AnnotationBo();
                bindValueAnnotation.setKey(AnnotationKey.SQL_BINDVALUE.getCode());
                bindValueAnnotation.setValue(bindValue);
                annotationBoList.add(bindValueAnnotation);
            }
        }
    });
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) SqlMetaDataBo(com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo) ArrayList(java.util.ArrayList) List(java.util.List)

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