Search in sources :

Example 1 with Record

use of com.navercorp.pinpoint.web.vo.callstacks.Record 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)

Example 2 with Record

use of com.navercorp.pinpoint.web.vo.callstacks.Record 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 3 with Record

use of com.navercorp.pinpoint.web.vo.callstacks.Record in project pinpoint by naver.

the class TraceViewerDataViewModel method initialize.

public void initialize() {
    int tid = 0;
    int arrowId = 0;
    String previousAppName = "";
    Record prev = null;
    Record possibleException = null;
    List<Stack<Record>> recordTraces = new ArrayList<Stack<Record>>();
    for (Record record : recordSet.getRecordList()) {
        if (record.getElapsed() != 0) {
            boolean isRecordHighlighted = StringUtils.equals(recordSet.getApplicationId(), record.getApplicationName());
            boolean isApplicationNameChanged = !previousAppName.equals(record.getApplicationName());
            if (recordTraces.size() == 0) {
                Stack<Record> recordTrace = new Stack<Record>();
                recordTrace.push(record);
                recordTraces.add(recordTrace);
                occupiedRange.add(new Long[] { record.getBegin(), record.getBegin() + record.getElapsed() });
            } else if (record.getApiType().equals("ASYNC")) {
                tid = newAsyncStack(tid, recordTraces, arrowId, record);
                arrowId++;
            } else if (isApplicationNameChanged && !isContinuingParentStack(recordTraces, tid, record)) {
                tid = newAsyncStack(tid, recordTraces, arrowId, record);
                arrowId++;
            } else {
                tid = updateRecordTrace(recordTraces, tid, record);
            }
            TraceEvent newTrace = TraceEvent.defaultTrace(tid, isRecordHighlighted, record, isApplicationNameChanged);
            traceEvents.add(newTrace);
            previousAppName = record.getApplicationName();
            prev = record;
        } else {
            if ((record.getTitle().equals("SQL") || (record.getTitle().equals("MONGO-JSON")))) {
                addQueryInfo(prev, record);
            }
            if (record.getHasException()) {
                if ((possibleException.getId() == record.getParentId())) {
                    addExceptionInfo(tid, prev, possibleException, record);
                }
            }
            addToInvisibleRecords(record);
        }
        possibleException = record;
    }
}
Also used : ArrayList(java.util.ArrayList) Record(com.navercorp.pinpoint.web.vo.callstacks.Record) Stack(java.util.Stack)

Example 4 with Record

use of com.navercorp.pinpoint.web.vo.callstacks.Record in project pinpoint by naver.

the class TransactionInfoViewModel method getCallStack.

@JsonProperty("callStack")
public List<CallStack> getCallStack() {
    List<CallStack> list = new ArrayList<CallStack>();
    boolean first = true;
    long barRatio = 0;
    for (Record record : recordSet.getRecordList()) {
        if (first) {
            if (record.isMethod()) {
                long begin = record.getBegin();
                long end = record.getBegin() + record.getElapsed();
                if (end - begin > 0) {
                    barRatio = 100 / (end - begin);
                }
            }
            first = false;
        }
        list.add(new CallStack(record, barRatio));
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Record(com.navercorp.pinpoint.web.vo.callstacks.Record) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty)

Aggregations

Record (com.navercorp.pinpoint.web.vo.callstacks.Record)4 RecordSet (com.navercorp.pinpoint.web.vo.callstacks.RecordSet)2 ArrayList (java.util.ArrayList)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Align (com.navercorp.pinpoint.web.calltree.span.Align)1 SpanAlign (com.navercorp.pinpoint.web.calltree.span.SpanAlign)1 Stack (java.util.Stack)1