Search in sources :

Example 6 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.

the class SpanServiceImpl method transitionCachedString.

private void transitionCachedString(List<SpanAlign> spans) {
    this.transitionAnnotation(spans, new AnnotationReplacementCallback() {

        @Override
        public void replacement(SpanAlign spanAlign, List<AnnotationBo> annotationBoList) {
            List<AnnotationBo> cachedStringAnnotation = findCachedStringAnnotation(annotationBoList);
            if (cachedStringAnnotation.isEmpty()) {
                return;
            }
            for (AnnotationBo annotationBo : cachedStringAnnotation) {
                final int cachedArgsKey = annotationBo.getKey();
                int stringMetaDataId = (Integer) annotationBo.getValue();
                List<StringMetaDataBo> stringMetaList = stringMetaDataDao.getStringMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), stringMetaDataId);
                int size = stringMetaList.size();
                if (size == 0) {
                    logger.warn("StringMetaData not Found {}/{}/{}", spanAlign.getAgentId(), stringMetaDataId, spanAlign.getAgentStartTime());
                    AnnotationBo api = new AnnotationBo();
                    api.setKey(AnnotationKey.ERROR_API_METADATA_NOT_FOUND.getCode());
                    api.setValue("CACHED-STRING-ID not found. stringId:" + cachedArgsKey);
                    annotationBoList.add(api);
                } else if (size >= 1) {
                    // key collision shouldn't really happen (probability too low)
                    StringMetaDataBo stringMetaDataBo = stringMetaList.get(0);
                    AnnotationBo stringMetaData = new AnnotationBo();
                    stringMetaData.setKey(AnnotationKeyUtils.cachedArgsToArgs(cachedArgsKey));
                    stringMetaData.setValue(stringMetaDataBo.getStringValue());
                    annotationBoList.add(stringMetaData);
                    if (size > 1) {
                        logger.warn("stringMetaData size not 1 :{}", stringMetaList);
                    }
                }
            }
        }
    });
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) ArrayList(java.util.ArrayList) List(java.util.List) StringMetaDataBo(com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)

Example 7 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.

the class SpanServiceImpl method selectSpan.

@Override
public SpanResult selectSpan(TransactionId transactionId, long selectedSpanHint) {
    if (transactionId == null) {
        throw new NullPointerException("transactionId must not be null");
    }
    final List<SpanBo> spans = traceDao.selectSpan(transactionId);
    if (CollectionUtils.isEmpty(spans)) {
        return new SpanResult(SpanAligner2.FAIL_MATCH, new CallTreeIterator(null));
    }
    final SpanResult result = order(spans, selectedSpanHint);
    final CallTreeIterator callTreeIterator = result.getCallTree();
    final List<SpanAlign> values = callTreeIterator.values();
    transitionDynamicApiId(values);
    transitionSqlId(values);
    transitionCachedString(values);
    transitionException(values);
    // TODO need to at least show the row data when root span is not found. 
    return result;
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) CallTreeIterator(com.navercorp.pinpoint.web.calltree.span.CallTreeIterator) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 8 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.

the class SpanServiceImpl method transitionDynamicApiId.

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

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

Example 9 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign in project pinpoint by naver.

the class RecordFactory method getFilteredRecord.

public Record getFilteredRecord(final CallTreeNode node, String apiTitle) {
    final SpanAlign align = node.getValue();
    align.setId(getNextId());
    final int parentId = getParentId(node);
    //        Api api = getApi(align);
    final Record record = new Record(align.getDepth(), align.getId(), parentId, true, apiTitle, "", align.getStartTime(), align.getElapsed(), align.getGap(), "UNKNOWN", align.getApplicationId(), ServiceType.UNKNOWN, "", false, false, align.getTransactionId(), align.getSpanId(), align.getExecutionMilliseconds(), MethodTypeEnum.DEFAULT, false);
    return record;
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign)

Aggregations

SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)9 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 StringMetaDataBo (com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)2 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SqlMetaDataBo (com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)1 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)1 CallTreeIterator (com.navercorp.pinpoint.web.calltree.span.CallTreeIterator)1 Record (com.navercorp.pinpoint.web.vo.callstacks.Record)1 RecordSet (com.navercorp.pinpoint.web.vo.callstacks.RecordSet)1