Search in sources :

Example 6 with Align

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

the class SpanServiceImpl method selectSpan.

@Override
public SpanResult selectSpan(TransactionId transactionId, Predicate<SpanBo> filter, ColumnGetCount columnGetCount) {
    Objects.requireNonNull(transactionId, "transactionId");
    Objects.requireNonNull(filter, "filter");
    Objects.requireNonNull(columnGetCount, "columnGetCount");
    final FetchResult<List<SpanBo>> fetchResult = traceDao.selectSpan(transactionId, columnGetCount);
    final List<SpanBo> spans = fetchResult.getData();
    logger.debug("selectSpan spans:{}", spans.size());
    populateAgentName(spans);
    if (CollectionUtils.isEmpty(spans)) {
        return new SpanResult(TraceState.State.ERROR, new CallTreeIterator(null));
    }
    final boolean isReachedLimit = columnGetCount.isReachedLimit(fetchResult.getFetchCount());
    final SpanResult result = order(spans, filter, isReachedLimit);
    final CallTreeIterator callTreeIterator = result.getCallTree();
    final List<Align> values = callTreeIterator.values();
    transitionDynamicApiId(values);
    transitionSqlId(values);
    transitionMongoJson(values);
    transitionCachedString(values);
    transitionException(values);
    // TODO need to at least show the row data when root span is not found.
    return result;
}
Also used : CallTreeIterator(com.navercorp.pinpoint.web.calltree.span.CallTreeIterator) Align(com.navercorp.pinpoint.web.calltree.span.Align) ArrayList(java.util.ArrayList) List(java.util.List) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 7 with Align

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

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

the class TransactionInfoServiceImpl method createRecordSet.

@Override
public RecordSet createRecordSet(CallTreeIterator callTreeIterator, Predicate<SpanBo> viewPointFilter) {
    Objects.requireNonNull(callTreeIterator, "callTreeIterator");
    Objects.requireNonNull(viewPointFilter, "viewPointFilter");
    RecordSet recordSet = new RecordSet();
    final List<Align> alignList = 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.
    Align viewPointAlign = findViewPoint(alignList, viewPointFilter);
    // FIXME patched temporarily for cases where focusTimeSpanBo is not found. Need a more complete solution.
    if (viewPointAlign != null) {
        recordSet.setAgentId(viewPointAlign.getAgentId());
        recordSet.setAgentName(viewPointAlign.getAgentName());
        recordSet.setApplicationId(viewPointAlign.getApplicationId());
        final String applicationName = getRpcArgument(viewPointAlign);
        recordSet.setApplicationName(applicationName);
    }
    // find the startTime to use as reference
    long startTime = getStartTime(alignList);
    recordSet.setStartTime(startTime);
    // find the endTime to use as reference
    long endTime = getEndTime(alignList);
    /*
         * Workaround codes to prevent issues occurred
         * when endTime is too far away from startTime
         */
    long rootEndTime = getRootEndTime(alignList);
    if (rootEndTime - startTime <= 0) {
        recordSet.setEndTime(endTime);
    } else if ((double) (rootEndTime - startTime) / (endTime - startTime) < 0.1) {
        recordSet.setEndTime(rootEndTime);
    } else {
        recordSet.setEndTime(endTime);
    }
    recordSet.setLoggingTransactionInfo(findIsLoggingTransactionInfo(alignList));
    final SpanAlignPopulate spanAlignPopulate = new SpanAlignPopulate();
    List<Record> recordList = spanAlignPopulate.populateSpanRecord(callTreeIterator);
    if (viewPointAlign != null) {
        // mark the record to be used as focus
        long beginTimeStamp = viewPointAlign.getStartTime();
        markFocusRecord(recordList, viewPointAlign);
        recordSet.setBeginTimestamp(beginTimeStamp);
    }
    recordSet.setRecordList(recordList);
    return recordSet;
}
Also used : Align(com.navercorp.pinpoint.web.calltree.span.Align) Record(com.navercorp.pinpoint.web.vo.callstacks.Record) RecordSet(com.navercorp.pinpoint.web.vo.callstacks.RecordSet)

Example 9 with Align

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

the class RecordFactoryTest method getException_check_argument.

@Test
public void getException_check_argument() {
    final RecordFactory factory = newRecordFactory();
    SpanBo spanBo = new SpanBo();
    spanBo.setTransactionId(new TransactionId("test", 0, 0));
    spanBo.setExceptionInfo(1, null);
    Align align = new SpanAlign(spanBo);
    Record exceptionRecord = factory.getException(0, 0, align);
    Assert.assertNotNull(exceptionRecord.getArguments());
}
Also used : SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) SpanAlign(com.navercorp.pinpoint.web.calltree.span.SpanAlign) Align(com.navercorp.pinpoint.web.calltree.span.Align) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Test(org.junit.Test)

Example 10 with Align

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

the class RecordFactory method getFilteredRecord.

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

Aggregations

Align (com.navercorp.pinpoint.web.calltree.span.Align)10 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 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 Api (com.navercorp.pinpoint.common.server.trace.Api)1 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)1 CallTreeIterator (com.navercorp.pinpoint.web.calltree.span.CallTreeIterator)1 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)1 Record (com.navercorp.pinpoint.web.vo.callstacks.Record)1 RecordSet (com.navercorp.pinpoint.web.vo.callstacks.RecordSet)1 Test (org.junit.Test)1