mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 16:28:48 +10:00
[강운덕] [LUCYSUS-1744] api depth 계산이 잘못되는 부분이 있어 수정함. 동일 depth일대 parent를 봐야 하는데. 바로전 depth를 보는 버그가 있음.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@2365 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -4,6 +4,8 @@ import java.util.*;
|
||||
|
||||
import com.nhn.pinpoint.common.bo.SpanBo;
|
||||
import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -11,6 +13,8 @@ import com.nhn.pinpoint.common.bo.SpanEventBo;
|
||||
*
|
||||
*/
|
||||
public class SpanAligner2 {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private static final Integer ROOT = -1;
|
||||
private final Map<Integer, SpanBo> spanMap;
|
||||
private Integer rootSpanId = null;
|
||||
@@ -52,7 +56,9 @@ public class SpanAligner2 {
|
||||
|
||||
private int populate(SpanBo parentSpan, int spanDepth, int sequence, int pSequence, List<SpanAlign> container) {
|
||||
int depth = spanDepth + 1;
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.info("span depth:{}", depth);
|
||||
}
|
||||
int lastChildSequence = sequence;
|
||||
|
||||
SpanAlign element = new SpanAlign(depth, parentSpan, ++lastChildSequence, pSequence);
|
||||
@@ -67,8 +73,15 @@ public class SpanAligner2 {
|
||||
|
||||
for (SpanEventBo spanEventBo : spanEventBoList) {
|
||||
if (spanEventBo.getDepth() != -1) {
|
||||
depth = spanDepth + spanEventBo.getDepth() + 1;
|
||||
}
|
||||
depth = spanDepth + spanEventBo.getDepth();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("spanEvent spanEvent{} depth:{} getDepth():{}", spanEventBo.getServiceType(), depth, spanEventBo.getDepth());
|
||||
}
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("spanEvent depth:{} ", depth);
|
||||
}
|
||||
}
|
||||
|
||||
lastChildSequence++;
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.nhn.pinpoint.web.service;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nhn.pinpoint.common.AnnotationKey;
|
||||
@@ -26,6 +27,8 @@ import com.nhn.pinpoint.web.vo.callstacks.RecordSet;
|
||||
@Service
|
||||
public class RecordSetServiceImpl implements RecordSetService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private ApiDescriptionParser apiDescriptionParser = new ApiDescriptionParser();
|
||||
|
||||
@Override
|
||||
@@ -54,6 +57,8 @@ public class RecordSetServiceImpl implements RecordSetService {
|
||||
recordSet.setEndTime(endTime);
|
||||
|
||||
List<Record> recordList = populateSpanRecord(spanAlignList);
|
||||
logger.debug("RecordList:{}", recordList);
|
||||
|
||||
// focus 대상 record를 체크한다.
|
||||
long beginTimeStamp = focusTimeSpanBo.getStartTime();
|
||||
markFocusRecord(recordList, beginTimeStamp);
|
||||
@@ -169,7 +174,7 @@ public class RecordSetServiceImpl implements RecordSetService {
|
||||
|
||||
// annotation id는 spanalign의 seq와 무관하게 순서대로 따도 됨. 겹치지만 않으면 됨.
|
||||
Integer annotationSeq = spanAlignList.size() + 1;
|
||||
Deque<Integer> stack = new LinkedList<Integer>();
|
||||
final LinkedList<Integer> stack = new LinkedList<Integer>();
|
||||
stack.add(-1);
|
||||
|
||||
int prevDepth = 0;
|
||||
@@ -180,8 +185,9 @@ public class RecordSetServiceImpl implements RecordSetService {
|
||||
int currentSeq = spanAlign.getSequence();
|
||||
int currentDepth = spanAlign.getDepth();
|
||||
|
||||
// System.out.println(i + ", prevDepth=" + prevDepth + ", currentDepth=" + currentDepth + ", currentSeq=" + currentSeq);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("before prevDepth:{}, currentSeq:{} currentDepth:{}", prevDepth, currentSeq, currentDepth);
|
||||
}
|
||||
if (i == 0) {
|
||||
// view에서 -1은 ""으로 변환됨. 최상위 노드의 부모는 ""로 표기되어야 하기 때문.
|
||||
parentSeq = -1;
|
||||
@@ -192,16 +198,22 @@ public class RecordSetServiceImpl implements RecordSetService {
|
||||
parentSeq = stack.getLast();
|
||||
stack.add(currentSeq);
|
||||
} else if (prevDepth > currentDepth) {
|
||||
stack.pollLast();
|
||||
Integer poll = stack.pollLast();
|
||||
logger.debug("pollLast:{}", poll);
|
||||
parentSeq = stack.getLast();
|
||||
} else {
|
||||
parentSeq = stack.getLast();
|
||||
|
||||
// parentSeq = stack.getLast();
|
||||
// 같은 depth일 경우는 parent를 불러야 한다.
|
||||
final int parentIndex = stack.size() - 2;
|
||||
// 인덱스 체크 필요.
|
||||
parentSeq = stack.get(parentIndex);
|
||||
}
|
||||
prevDepth = currentDepth;
|
||||
}
|
||||
|
||||
// System.out.println("\tparent=" + parentSeq);
|
||||
// System.out.println(stack);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("after parentSeq:{} prevDepth:{}, currentSeq:{} currentDepth:{}", parentSeq, prevDepth, currentSeq, currentDepth);
|
||||
}
|
||||
|
||||
if (spanAlign.isSpan()) {
|
||||
SpanBo spanBo = spanAlign.getSpanBo();
|
||||
|
||||
@@ -322,7 +322,9 @@ public class SpanServiceImpl implements SpanService {
|
||||
|
||||
private List<SpanAlign> order(List<SpanBo> spans) {
|
||||
SpanAligner2 spanAligner = new SpanAligner2(spans);
|
||||
return spanAligner.sort();
|
||||
List<SpanAlign> sort = spanAligner.sort();
|
||||
logger.debug("SpanAlignList:{}", sort);
|
||||
return sort;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,9 +147,28 @@ public class Record {
|
||||
public boolean getHasChild() {
|
||||
return hasChild;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Record [tab=" + tab + ", method=" + method + ", title=" + title + ", arguments=" + arguments + ", begin=" + begin + ", elapsed=" + elapsed + ", agent=" + agent + ", service=" + service + "]";
|
||||
}
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("Record{");
|
||||
sb.append("tab=").append(tab);
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", pId=").append(pId);
|
||||
sb.append(", method=").append(method);
|
||||
sb.append(", title='").append(title).append('\'');
|
||||
sb.append(", simpleClassName='").append(simpleClassName).append('\'');
|
||||
sb.append(", fullApiDescription='").append(fullApiDescription).append('\'');
|
||||
sb.append(", arguments='").append(arguments).append('\'');
|
||||
sb.append(", begin=").append(begin);
|
||||
sb.append(", elapsed=").append(elapsed);
|
||||
sb.append(", agent='").append(agent).append('\'');
|
||||
sb.append(", service='").append(service).append('\'');
|
||||
sb.append(", serviceType=").append(serviceType);
|
||||
sb.append(", destinationId='").append(destinationId).append('\'');
|
||||
sb.append(", excludeFromTimeline=").append(excludeFromTimeline);
|
||||
sb.append(", focused=").append(focused);
|
||||
sb.append(", hasChild=").append(hasChild);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user