Search in sources :

Example 1 with SpanAlign

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

the class RecordFactory method get.

public Record get(final CallTreeNode node, final String argument) {
    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, api.getTitle(), argument, align.getStartTime(), align.getElapsed(), align.getGap(), align.getAgentId(), align.getApplicationId(), registry.findServiceType(align.getServiceType()), align.getDestinationId(), align.hasChild(), false, align.getTransactionId(), align.getSpanId(), align.getExecutionMilliseconds(), api.getMethodTypeEnum(), true);
    record.setSimpleClassName(api.getClassName());
    record.setFullApiDescription(api.getDescription());
    return record;
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign)

Example 2 with SpanAlign

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

the class SpanServiceImpl method transitionException.

private void transitionException(List<SpanAlign> spanAlignList) {
    for (SpanAlign spanAlign : spanAlignList) {
        if (spanAlign.hasException()) {
            StringMetaDataBo stringMetaData = selectStringMetaData(spanAlign.getAgentId(), spanAlign.getExceptionId(), spanAlign.getAgentStartTime());
            spanAlign.setExceptionClass(stringMetaData.getStringValue());
        }
    }
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) StringMetaDataBo(com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)

Example 3 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign 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 4 with SpanAlign

use of com.navercorp.pinpoint.web.calltree.span.SpanAlign 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)

Example 5 with SpanAlign

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

the class TransactionInfoServiceImpl method createRecordSet.

@Override
public RecordSet createRecordSet(CallTreeIterator callTreeIterator, long focusTimestamp, String agentId, long spanId) {
    if (callTreeIterator == null) {
        throw new NullPointerException("callTreeIterator must not be null");
    }
    RecordSet recordSet = new RecordSet();
    final List<SpanAlign> spanAlignList = callTreeIterator.values();
    // finds and marks the viewPoint.base on focusTimestamp.
    // focusTimestamp is needed to determine which span to use as reference when there are more than 2 spans making up a transaction.
    // for cases where focus cannot be found due to an error, a separate marker is needed.
    // TODO potential error - because server time is used, there may be more than 2 focusTime due to differences in server times.
    SpanAlign viewPointSpanAlign = findViewPoint(spanAlignList, focusTimestamp, agentId, spanId);
    // FIXME patched temporarily for cases where focusTimeSpanBo is not found. Need a more complete solution.
    if (viewPointSpanAlign != null) {
        recordSet.setAgentId(viewPointSpanAlign.getAgentId());
        recordSet.setApplicationId(viewPointSpanAlign.getApplicationId());
        final String applicationName = getRpcArgument(viewPointSpanAlign);
        recordSet.setApplicationName(applicationName);
    }
    // find the startTime to use as reference
    long startTime = getStartTime(spanAlignList);
    recordSet.setStartTime(startTime);
    // find the endTime to use as reference
    long endTime = getEndTime(spanAlignList);
    recordSet.setEndTime(endTime);
    recordSet.setLoggingTransactionInfo(findIsLoggingTransactionInfo(spanAlignList));
    final SpanAlignPopulate spanAlignPopulate = new SpanAlignPopulate();
    List<Record> recordList = spanAlignPopulate.populateSpanRecord(callTreeIterator);
    logger.debug("RecordList:{}", recordList);
    if (viewPointSpanAlign != null) {
        // mark the record to be used as focus
        long beginTimeStamp = viewPointSpanAlign.getStartTime();
        markFocusRecord(recordList, viewPointSpanAlign);
        recordSet.setBeginTimestamp(beginTimeStamp);
    }
    recordSet.setRecordList(recordList);
    return recordSet;
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) Record(com.navercorp.pinpoint.web.vo.callstacks.Record) RecordSet(com.navercorp.pinpoint.web.vo.callstacks.RecordSet)

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 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)2 StringMetaDataBo (com.navercorp.pinpoint.common.server.bo.StringMetaDataBo)2 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 SqlMetaDataBo (com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)1 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)1 Align (com.navercorp.pinpoint.web.calltree.span.Align)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 Test (org.junit.Test)1