diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseTraceDao.java b/collector/src/main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseTraceDao.java index c5676fca6f6b..d0f87771f460 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseTraceDao.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseTraceDao.java @@ -138,7 +138,7 @@ private void addColumn(Put put, BasicSpan basicSpan, SpanEventBo spanEventBo) { if (!spanEventFilter.filter(spanEventBo)) { return; } - SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(basicSpan.getSpanId(), spanEventBo); + SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(basicSpan, spanEventBo); this.spanEventSerializer.serialize(spanEventEncodingContext, put, null); } diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java index 9b48a9ef596e..fbe98d7c7333 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanEventBo.java @@ -18,8 +18,6 @@ import java.util.List; -import com.navercorp.pinpoint.common.util.TransactionId; - /** * @author emeroad * @author jaehong.kim @@ -30,12 +28,6 @@ public class SpanEventBo implements Event { private byte version = 0; - private String agentId; - private String applicationId; - private long agentStartTime; - - private TransactionId transactionId; - private short sequence; private int startElapsed; @@ -76,39 +68,6 @@ public void setVersion(byte version) { this.version = version; } - public String getAgentId() { - return agentId; - } - - public void setAgentId(String agentId) { - this.agentId = agentId; - } - - public String getApplicationId() { - return applicationId; - } - - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; - } - - public long getAgentStartTime() { - return this.agentStartTime; - } - - public void setAgentStartTime(long agentStartTime) { - this.agentStartTime = agentStartTime; - } - - public TransactionId getTransactionId() { - return transactionId; - } - - public void setTransactionId(TransactionId transactionId) { - this.transactionId = transactionId; - } - - public short getSequence() { return sequence; } @@ -263,14 +222,6 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append("{version="); builder.append(version); - builder.append(", agentId="); - builder.append(agentId); - builder.append(", applicationId="); - builder.append(applicationId); - builder.append(", agentStartTime="); - builder.append(agentStartTime); - builder.append(", transactionId="); - builder.append(transactionId); builder.append(", sequence="); builder.append(sequence); builder.append(", startElapsed="); diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanFactory.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanFactory.java index 01280481591b..2eb4635d9859 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanFactory.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/SpanFactory.java @@ -53,7 +53,7 @@ public SpanBo buildSpanBo(TSpan tSpan) { final SpanBo spanBo = newSpanBo(tSpan); List spanEventList = tSpan.getSpanEventList(); - List spanEventBoList = buildSpanEventBoList(spanBo, spanEventList); + List spanEventBoList = buildSpanEventBoList(spanEventList); spanBo.addSpanEventBoList(spanEventBoList); long acceptedTime = acceptedTimeService.getAcceptedTime(); @@ -117,28 +117,6 @@ SpanBo newSpanBo(TSpan tSpan) { } - // for test - SpanEventBo newSpanEventBo(BasicSpan basicSpan, TSpanEvent tSpanEvent) { - if (basicSpan == null) { - throw new NullPointerException("basicSpan must not be null"); - } - if (tSpanEvent == null) { - throw new NullPointerException("tSpanEvent must not be null"); - } - - final SpanEventBo spanEvent = new SpanEventBo(); - spanEvent.setAgentId(basicSpan.getAgentId()); - spanEvent.setApplicationId(basicSpan.getApplicationId()); - spanEvent.setAgentStartTime(basicSpan.getAgentStartTime()); -// spanEvent.setSpanId(basicSpan.getSpanId()); - - TransactionId transactionId = basicSpan.getTransactionId(); - spanEvent.setTransactionId(transactionId); - - bind(spanEvent, tSpanEvent); - return spanEvent; - } - private void bind(SpanEventBo spanEvent, TSpanEvent tSpanEvent) { spanEvent.setSequence(tSpanEvent.getSequence()); @@ -190,7 +168,7 @@ public SpanChunkBo buildSpanChunkBo(TSpanChunk tSpanChunk) { final SpanChunkBo spanChunkBo = newSpanChunkBo(tSpanChunk); List spanEventList = tSpanChunk.getSpanEventList(); - List spanEventBoList = buildSpanEventBoList(spanChunkBo, spanEventList); + List spanEventBoList = buildSpanEventBoList(spanEventList); spanChunkBo.addSpanEventBoList(spanEventBoList); @@ -233,13 +211,13 @@ private TransactionId newTransactionId(byte[] transactionIdBytes, BasicSpan basi } - private List buildSpanEventBoList(BasicSpan basicSpan, List spanEventList) { + private List buildSpanEventBoList(List spanEventList) { if (CollectionUtils.isEmpty(spanEventList)) { return new ArrayList<>(); } List spanEventBoList = new ArrayList<>(spanEventList.size()); for (TSpanEvent tSpanEvent : spanEventList) { - final SpanEventBo spanEventBo = newSpanEventBo(basicSpan, tSpanEvent); + final SpanEventBo spanEventBo = buildSpanEventBo(tSpanEvent); if (!spanEventFilter.filter(spanEventBo)) { continue; } @@ -265,9 +243,14 @@ private List buildAnnotationList(List tAnnotationList } // for test - public SpanEventBo buildSpanEventBo(TSpan tSpan, TSpanEvent tSpanEvent) { - SpanBo spanBo = newSpanBo(tSpan); - return newSpanEventBo(spanBo, tSpanEvent); + public SpanEventBo buildSpanEventBo(TSpanEvent tSpanEvent) { + if (tSpanEvent == null) { + throw new NullPointerException("tSpanEvent must not be null"); + } + + final SpanEventBo spanEvent = new SpanEventBo(); + bind(spanEvent, tSpanEvent); + return spanEvent; } private AnnotationBo newAnnotationBo(TAnnotation tAnnotation) { diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecoder.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecoder.java index c162dcbc2783..023dfb06ba1c 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecoder.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecoder.java @@ -92,9 +92,7 @@ int readSpan(SpanBo span, Buffer buffer) { } public SpanEventBo decodeSpanEventBo(Buffer qualifier, Buffer valueBuffer, SpanDecodingContext decodingContext) { - TransactionId transactionId = decodingContext.getTransactionId(); SpanEventBo spanEventBo = new SpanEventBo(); - spanEventBo.setTransactionId(transactionId); long spanId = qualifier.readLong(); decodingContext.setSpanId(spanId); @@ -112,7 +110,7 @@ public SpanEventBo decodeSpanEventBo(Buffer qualifier, Buffer valueBuffer, SpanD spanEventBo.setAsyncId(asyncId); spanEventBo.setAsyncSequence(asyncSequence); - readSpanEvent(spanEventBo, valueBuffer); + readSpanEvent(spanEventBo, valueBuffer, decodingContext); if (logger.isDebugEnabled()) { logger.debug("read spanEvent :{}", spanEventBo); } @@ -120,13 +118,13 @@ public SpanEventBo decodeSpanEventBo(Buffer qualifier, Buffer valueBuffer, SpanD } // for test - int readSpanEvent(final SpanEventBo spanEvent, Buffer buffer) { + int readSpanEvent(final SpanEventBo spanEvent, Buffer buffer, SpanDecodingContext decodingContext) { spanEvent.setVersion(buffer.readByte()); - spanEvent.setAgentId(buffer.readPrefixedString()); - spanEvent.setApplicationId(buffer.readPrefixedString()); - spanEvent.setAgentStartTime(buffer.readVLong()); + decodingContext.setAgentId(buffer.readPrefixedString()); + decodingContext.setApplicationId(buffer.readPrefixedString()); + decodingContext.setAgentStartTime(buffer.readVLong()); spanEvent.setStartElapsed(buffer.readVInt()); spanEvent.setEndElapsed(buffer.readVInt()); diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecodingContext.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecodingContext.java index 5816daa4a928..e2393cd2cba0 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecodingContext.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanDecodingContext.java @@ -7,10 +7,37 @@ */ public class SpanDecodingContext { + private String agentId; + private String applicationId; + private long agentStartTime; + private long spanId; private long collectorAcceptedTime; private TransactionId transactionId; + public String getAgentId() { + return agentId; + } + + public void setAgentId(String agentId) { + this.agentId = agentId; + } + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public long getAgentStartTime() { + return agentStartTime; + } + + public void setAgentStartTime(long agentStartTime) { + this.agentStartTime = agentStartTime; + } public long getSpanId() { return spanId; diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventEncodingContext.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventEncodingContext.java index 60296f67b7a6..8ccbbcba4a0c 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventEncodingContext.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventEncodingContext.java @@ -1,21 +1,28 @@ package com.navercorp.pinpoint.common.server.bo.serializer.trace.v1; +import com.navercorp.pinpoint.common.server.bo.BasicSpan; import com.navercorp.pinpoint.common.server.bo.SpanEventBo; /** * @author Woonduk Kang(emeroad) */ public class SpanEventEncodingContext { - private final long spanId; + private final BasicSpan basicSpan; private final SpanEventBo spanEventBo; - public SpanEventEncodingContext(long spanId, SpanEventBo spanEventBo) { - this.spanId = spanId; + public SpanEventEncodingContext(BasicSpan basicSpan, SpanEventBo spanEventBo) { + if (basicSpan == null) { + throw new NullPointerException("basicSpan must not be null"); + } + if (spanEventBo == null) { + throw new NullPointerException("spanEventBo must not be null"); + } + this.basicSpan = basicSpan; this.spanEventBo = spanEventBo; } - public long getSpanId() { - return spanId; + public BasicSpan getBasicSpan() { + return basicSpan; } public SpanEventBo getSpanEventBo() { diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventSerializer.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventSerializer.java index 775cd3afae2c..52ddf7bf591c 100644 --- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventSerializer.java +++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventSerializer.java @@ -3,6 +3,7 @@ import com.navercorp.pinpoint.common.buffer.AutomaticBuffer; import com.navercorp.pinpoint.common.buffer.Buffer; import com.navercorp.pinpoint.common.server.bo.AnnotationBo; +import com.navercorp.pinpoint.common.server.bo.BasicSpan; import com.navercorp.pinpoint.common.server.bo.SpanEventBo; import com.navercorp.pinpoint.common.server.bo.serializer.HbaseSerializer; import com.navercorp.pinpoint.common.server.bo.serializer.SerializationContext; @@ -43,8 +44,10 @@ public void serialize(SpanEventEncodingContext spanEventEncodingContext, Put put private ByteBuffer writeQualifier(SpanEventEncodingContext spanEventEncodingContext) { SpanEventBo spanEventBo = spanEventEncodingContext.getSpanEventBo(); + BasicSpan basicSpan = spanEventEncodingContext.getBasicSpan(); + final Buffer rowId = new AutomaticBuffer(); - rowId.putLong(spanEventEncodingContext.getSpanId()); + rowId.putLong(basicSpan.getSpanId()); rowId.putShort(spanEventBo.getSequence()); rowId.putInt(spanEventBo.getAsyncId()); rowId.putShort(spanEventBo.getAsyncSequence()); @@ -53,13 +56,15 @@ private ByteBuffer writeQualifier(SpanEventEncodingContext spanEventEncodingCont public ByteBuffer writeValue(SpanEventEncodingContext spanEventEncodingContext) { SpanEventBo spanEventBo = spanEventEncodingContext.getSpanEventBo(); + BasicSpan basicSpan = spanEventEncodingContext.getBasicSpan(); + final Buffer buffer = new AutomaticBuffer(512); buffer.putByte(spanEventBo.getVersion()); - buffer.putPrefixedString(spanEventBo.getAgentId()); - buffer.putPrefixedString(spanEventBo.getApplicationId()); - buffer.putVLong(spanEventBo.getAgentStartTime()); + buffer.putPrefixedString(basicSpan.getAgentId()); + buffer.putPrefixedString(basicSpan.getApplicationId()); + buffer.putVLong(basicSpan.getAgentStartTime()); buffer.putVInt(spanEventBo.getStartElapsed()); buffer.putVInt(spanEventBo.getEndElapsed()); diff --git a/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/SpanFactoryTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/SpanFactoryTest.java index 0ab14fdc62eb..ca92f276dc27 100644 --- a/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/SpanFactoryTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/SpanFactoryTest.java @@ -61,11 +61,9 @@ public void testNewSpanChunkBo_N() throws Exception { @Test public void testNewSpanEventBo() throws Exception { - TSpan tSpan = random.randomTSpan(); - SpanBo spanBo = spanFactory.newSpanBo(tSpan); TSpanEvent tSpanEvent = random.randomTSpanEvent((short) RandomUtils.nextInt(0, 100)); - SpanEventBo spanEventBo = spanFactory.newSpanEventBo(spanBo, tSpanEvent); + SpanEventBo spanEventBo = spanFactory.buildSpanEventBo(tSpanEvent); spanFactoryAssert.assertSpanEvent(tSpanEvent, spanEventBo); diff --git a/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventBoTest.java b/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventBoTest.java index 886b1dde4f16..40a97423d10d 100644 --- a/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventBoTest.java +++ b/commons-server/src/test/java/com/navercorp/pinpoint/common/server/bo/serializer/trace/v1/SpanEventBoTest.java @@ -18,10 +18,10 @@ import com.navercorp.pinpoint.common.buffer.Buffer; import com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer; +import com.navercorp.pinpoint.common.server.bo.SpanBo; import com.navercorp.pinpoint.common.server.bo.SpanEventBo; import com.navercorp.pinpoint.common.trace.ServiceType; -import com.navercorp.pinpoint.common.util.TransactionId; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -48,9 +48,13 @@ public void setUp() throws Exception { @Test public void testSerialize() throws Exception { + SpanBo spanBo = new SpanBo(); + spanBo.setAgentId("testAgent"); + spanBo.setApplicationId("testApp"); + spanBo.setAgentStartTime(1); + spanBo.setSpanId(12); + SpanEventBo spanEventBo = new SpanEventBo(); - spanEventBo.setAgentId("test"); - spanEventBo.setAgentStartTime(1); spanEventBo.setDepth(3); spanEventBo.setDestinationId("testdest"); spanEventBo.setEndElapsed(2); @@ -63,17 +67,19 @@ public void testSerialize() throws Exception { spanEventBo.setStartElapsed(100); spanEventBo.setNextAsyncId(1000); - SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(12, spanEventBo); + SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(spanBo, spanEventBo); ByteBuffer bytes = serializer.writeValue(spanEventEncodingContext); SpanEventBo newSpanEventBo = new SpanEventBo(); + SpanDecodingContext spanDecodingContext = new SpanDecodingContext(); Buffer buffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining()); - int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer); + int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer, spanDecodingContext); Assert.assertEquals(bytes.limit(), i); - Assert.assertEquals(spanEventBo.getAgentId(), newSpanEventBo.getAgentId()); - Assert.assertEquals(spanEventBo.getAgentStartTime(), newSpanEventBo.getAgentStartTime()); + Assert.assertEquals(spanBo.getAgentId(), spanDecodingContext.getAgentId()); + Assert.assertEquals(spanBo.getApplicationId(), spanDecodingContext.getApplicationId()); + Assert.assertEquals(spanBo.getAgentStartTime(), spanDecodingContext.getAgentStartTime()); Assert.assertEquals(spanEventBo.getDepth(), newSpanEventBo.getDepth()); Assert.assertEquals(spanEventBo.getDestinationId(), newSpanEventBo.getDestinationId()); Assert.assertEquals(spanEventBo.getEndElapsed(), newSpanEventBo.getEndElapsed()); @@ -87,11 +93,6 @@ public void testSerialize() throws Exception { Assert.assertEquals(spanEventBo.getNextAsyncId(), newSpanEventBo.getNextAsyncId()); - TransactionId transactionId = new TransactionId("test", 3, 1); - spanEventBo.setTransactionId(transactionId); - newSpanEventBo.setTransactionId(transactionId); - Assert.assertEquals(spanEventBo.getTransactionId(), newSpanEventBo.getTransactionId()); - spanEventBo.setSequence((short) 3); newSpanEventBo.setSequence((short) 3); Assert.assertEquals(spanEventBo.getSequence(), newSpanEventBo.getSequence()); diff --git a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java b/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java index 5e4c05f27854..4f844b95f879 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/test/junit4/BasePinpointTest.java @@ -53,7 +53,7 @@ protected List getCurrentSpanEvents() { for (TBase span : this.tBaseRecorder) { if (span instanceof SpanEvent) { SpanEvent spanEvent = (SpanEvent)span; - SpanEventBo spanEventBo = spanFactory.buildSpanEventBo(spanEvent.getSpan(), spanEvent); + SpanEventBo spanEventBo = spanFactory.buildSpanEventBo(spanEvent); spanEvents.add(spanEventBo); } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CorruptedSpanAlignFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CorruptedSpanAlignFactory.java index 94f9fde0df09..88d48ca7deea 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CorruptedSpanAlignFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CorruptedSpanAlignFactory.java @@ -45,8 +45,6 @@ public SpanAlign get(final String title, final SpanBo span, final SpanEventBo sp missedEvent.setStartElapsed(spanEvent.getStartElapsed()); missedEvent.setEndElapsed(spanEvent.getEndElapsed()); - missedEvent.setAgentId(span.getAgentId()); - missedEvent.setAgentStartTime(span.getAgentStartTime()); missedEvent.setServiceType(ServiceType.COLLECTOR.getCode()); List annotations = new ArrayList<>(); diff --git a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanAlign.java b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanAlign.java index 5121968716a5..4d99b890579b 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanAlign.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanAlign.java @@ -78,7 +78,7 @@ public SpanEventBo getSpanEventBo() { return spanEventBo; } - public boolean isHasChild() { + public boolean hasChild() { return hasChild; } @@ -130,6 +130,14 @@ public void setExecutionMilliseconds(long executionMilliseconds) { this.executionMilliseconds = executionMilliseconds; } + public long getCollectorAcceptTime() { + return spanBo.getCollectorAcceptTime(); + } + + public byte getLoggingTransactionInfo() { + return spanBo.getLoggingTransactionInfo(); + } + public long getLastTime() { if (isSpan()) { return spanBo.getStartTime() + spanBo.getElapsed(); @@ -155,16 +163,17 @@ public long getElapsed() { } public String getAgentId() { - if (isSpan()) { - return spanBo.getAgentId(); - } - return spanEventBo.getAgentId(); + return spanBo.getAgentId(); } public String getApplicationId() { return spanBo.getApplicationId(); } + public long getAgentStartTime() { + return spanBo.getAgentStartTime(); + } + public short getServiceType() { if (isSpan()) { return spanBo.getServiceType(); @@ -181,21 +190,36 @@ public long getSpanId() { } public boolean hasException() { - if(isSpan()) { + if (isSpan()) { return spanBo.hasException(); } return spanEventBo.hasException(); } - + + public int getExceptionId() { + if (isSpan()) { + return spanBo.getExceptionId(); + } + return spanEventBo.getExceptionId(); + } + public String getExceptionClass() { - if(isSpan()) { + if (isSpan()) { return spanBo.getExceptionClass(); } return spanEventBo.getExceptionClass(); } + + public void setExceptionClass(String exceptionClass) { + if (isSpan()) { + spanBo.setExceptionClass(exceptionClass); + } else { + spanEventBo.setExceptionClass(exceptionClass); + } + } public String getExceptionMessage() { - if(isSpan()) { + if (isSpan()) { return spanBo.getExceptionMessage(); } @@ -203,22 +227,38 @@ public String getExceptionMessage() { } public String getRemoteAddr() { - if(isSpan()) { + if (isSpan()) { return spanBo.getRemoteAddr(); } return null; } + public int getApiId() { + if (isSpan()) { + return spanBo.getApiId(); + } else { + return spanEventBo.getApiId(); + } + } + public List getAnnotationBoList() { - if(isSpan()) { + if (isSpan()) { return spanBo.getAnnotationBoList(); } return spanEventBo.getAnnotationBoList(); } + + public void setAnnotationBoList(List annotationBoList) { + if (isSpan()) { + spanBo.setAnnotationBoList(annotationBoList); + } else { + spanEventBo.setAnnotationBoList(annotationBoList); + } + } public String getDestinationId() { - if(isSpan()) { + if (isSpan()) { return null; } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapper.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapper.java index 2f878d3eea0c..285ddff7c601 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapper.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapper.java @@ -19,7 +19,6 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; -import com.navercorp.pinpoint.common.PinpointConstants; import com.navercorp.pinpoint.common.buffer.Buffer; import com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer; import com.navercorp.pinpoint.common.server.bo.AnnotationBo; @@ -45,6 +44,8 @@ import java.util.*; +import static com.navercorp.pinpoint.web.mapper.SpanMapperV2.*; + /** * @author emeroad */ @@ -79,8 +80,8 @@ public List mapRow(Result result, int rowNum) throws Exception { final Cell[] rawCells = result.rawCells(); - Map spanMap = new LinkedHashMap<>(); - ListMultimap spanEventBoListMap = ArrayListMultimap.create(); + Map spanMap = new LinkedHashMap<>(); + ListMultimap spanEventBoListMap = ArrayListMultimap.create(); ListMultimap annotationBoListMap = ArrayListMultimap.create(); final SpanDecodingContext decodingContext = new SpanDecodingContext(); @@ -96,15 +97,18 @@ public List mapRow(Result result, int rowNum) throws Exception { Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); final SpanBo spanBo = spanDecoder.decodeSpanBo(qualifierBuffer, valueBuffer, decodingContext); - spanMap.put(spanBo.getSpanId(), spanBo); + + AgentKey agentKey = newAgentKey(spanBo); + spanMap.put(agentKey, spanBo); } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_TERMINALSPAN)) { final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); SpanEventBo spanEventBo = spanDecoder.decodeSpanEventBo(qualifier, valueBuffer, decodingContext); - long spanId = decodingContext.getSpanId(); - spanEventBoListMap.put(spanId, spanEventBo); + + AgentKey agentKey = newAgentKey(decodingContext); + spanEventBoListMap.put(agentKey, spanEventBo); } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_ANNOTATION)) { @@ -121,9 +125,9 @@ public List mapRow(Result result, int rowNum) throws Exception { } decodingContext.finish(); - for (Map.Entry spanBoEntry : spanEventBoListMap.entries()) { - final Long spanId = spanBoEntry.getKey(); - SpanBo spanBo = spanMap.get(spanId); + for (Map.Entry spanBoEntry : spanEventBoListMap.entries()) { + final AgentKey agentKey = spanBoEntry.getKey(); + SpanBo spanBo = spanMap.get(agentKey); if (spanBo != null) { SpanEventBo value = spanBoEntry.getValue(); spanBo.addSpanEvent(value); @@ -144,15 +148,20 @@ public List mapRow(Result result, int rowNum) throws Exception { } + private AgentKey newAgentKey(SpanBo spanBo) { + return new AgentKey(spanBo.getApplicationId(), spanBo.getAgentId(), spanBo.getAgentStartTime(), spanBo.getSpanId()); + } + + private AgentKey newAgentKey(SpanDecodingContext decodingContext) { + return new AgentKey(decodingContext.getApplicationId(), decodingContext.getAgentId(), decodingContext.getAgentStartTime(), decodingContext.getSpanId()); + } private void addAnnotation(List spanList, ListMultimap annotationMap) { - for (SpanBo bo : spanList) { - long spanID = bo.getSpanId(); - List anoList = annotationMap.get(spanID); - bo.setAnnotationBoList(anoList); + for (SpanBo spanBo : spanList) { + long spanId = spanBo.getSpanId(); + List anoList = annotationMap.get(spanId); + spanBo.setAnnotationBoList(anoList); } } - - } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapperV2.java b/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapperV2.java index b22b5e70111b..33334ac2c3eb 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapperV2.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/mapper/SpanMapperV2.java @@ -24,6 +24,7 @@ import com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer; import com.navercorp.pinpoint.common.hbase.HBaseTables; import com.navercorp.pinpoint.common.hbase.RowMapper; +import com.navercorp.pinpoint.common.server.bo.BasicSpan; import com.navercorp.pinpoint.common.server.bo.SpanBo; import com.navercorp.pinpoint.common.server.bo.SpanChunkBo; import com.navercorp.pinpoint.common.server.bo.SpanEventBo; @@ -82,7 +83,7 @@ public List mapRow(Result result, int rowNum) throws Exception { final Cell[] rawCells = result.rawCells(); - ListMultimap spanMap = LinkedListMultimap.create(); + ListMultimap spanMap = LinkedListMultimap.create(); List spanChunkList = new ArrayList<>(); final SpanDecodingContext decodingContext = new SpanDecodingContext(); @@ -105,7 +106,8 @@ public List mapRow(Result result, int rowNum) throws Exception { if (logger.isDebugEnabled()) { logger.debug("spanBo:{}", spanBo); } - spanMap.put(spanBo.getSpanId(), spanBo); + AgentKey agentKey = newAgentKey(spanBo); + spanMap.put(agentKey, spanBo); } else if (decodeObject instanceof SpanChunkBo) { SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject; if (logger.isDebugEnabled()) { @@ -144,33 +146,24 @@ private SpanDecoder resolveDecoder(Buffer columnValue) { } - private List buildSpanBoList(ListMultimap spanMap, List spanChunkList) { + private List buildSpanBoList(ListMultimap spanMap, List spanChunkList) { List spanBoList = bindSpanChunk(spanMap, spanChunkList); - bindAgentInfo(spanBoList); + sortSpanEvent(spanBoList); return spanBoList; } - private void bindAgentInfo(List spanBoList) { - // TODO workaround. fix class dependency + private void sortSpanEvent(List spanBoList) { for (SpanBo spanBo : spanBoList) { List spanEventBoList = spanBo.getSpanEventBoList(); Collections.sort(spanEventBoList, SpanEventComparator.INSTANCE); - - for (SpanEventBo spanEventBo : spanEventBoList) { - spanEventBo.setAgentId(spanBo.getAgentId()); - spanEventBo.setApplicationId(spanBo.getApplicationId()); - spanEventBo.setAgentStartTime(spanBo.getAgentStartTime()); - - spanEventBo.setTransactionId(spanBo.getTransactionId()); - } } } - private List bindSpanChunk(ListMultimap spanMap, List spanChunkList) { + private List bindSpanChunk(ListMultimap spanMap, List spanChunkList) { for (SpanChunkBo spanChunkBo : spanChunkList) { - final Long spanId = spanChunkBo.getSpanId(); - List matchedSpanBoList = spanMap.get(spanId); + AgentKey agentKey = newAgentKey(spanChunkBo); + List matchedSpanBoList = spanMap.get(agentKey); if (matchedSpanBoList != null) { final int spanIdCollisionSize = matchedSpanBoList.size(); if (spanIdCollisionSize > 1) { @@ -191,10 +184,68 @@ private List bindSpanChunk(ListMultimap spanMap, List>> 32)); + result = 31 * result + applicationId.hashCode(); + result = 31 * result + agentId.hashCode(); + result = 31 * result + (int) (agentStartTime ^ (agentStartTime >>> 32)); + return result; + } + + @Override + public String toString() { + return "AgentKey{" + + "spanId=" + spanId + + ", applicationId='" + applicationId + '\'' + + ", agentId='" + agentId + '\'' + + ", agentStartTime=" + agentStartTime + + '}'; + } + } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java index c8a972e76645..35cdb4b7f9b5 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/SpanServiceImpl.java @@ -79,6 +79,10 @@ public class SpanServiceImpl implements SpanService { private final SqlParser sqlParser = new DefaultSqlParser(); private final OutputParameterParser outputParameterParser = new OutputParameterParser(); + public void setSqlMetaDataDao(SqlMetaDataDao sqlMetaDataDao) { + this.sqlMetaDataDao = sqlMetaDataDao; + } + @Override public SpanResult selectSpan(TransactionId transactionId, long selectedSpanHint) { if (transactionId == null) { @@ -106,22 +110,12 @@ public SpanResult selectSpan(TransactionId transactionId, long selectedSpanHint) private void transitionAnnotation(List spans, AnnotationReplacementCallback annotationReplacementCallback) { for (SpanAlign spanAlign : spans) { - List annotationBoList; - if (spanAlign.isSpan()) { - annotationBoList = spanAlign.getSpanBo().getAnnotationBoList(); - if (annotationBoList == null) { - annotationBoList = new ArrayList<>(); - spanAlign.getSpanBo().setAnnotationBoList(annotationBoList); - } - annotationReplacementCallback.replacement(spanAlign, annotationBoList); - } else { - annotationBoList = spanAlign.getSpanEventBo().getAnnotationBoList(); - if (annotationBoList == null) { - annotationBoList = new ArrayList<>(); - spanAlign.getSpanEventBo().setAnnotationBoList(annotationBoList); - } - annotationReplacementCallback.replacement(spanAlign, annotationBoList); + List annotationBoList = spanAlign.getAnnotationBoList(); + if (annotationBoList == null) { + annotationBoList = new ArrayList<>(); + spanAlign.setAnnotationBoList(annotationBoList); } + annotationReplacementCallback.replacement(spanAlign, annotationBoList); } } @@ -139,18 +133,16 @@ public void replacement(SpanAlign spanAlign, List annotationBoList return; } - final AgentKey agentKey = getAgentKey(spanAlign); - // value of sqlId's annotation contains multiple values. final IntStringStringValue sqlValue = (IntStringStringValue) sqlIdAnnotation.getValue(); - final int hashCode = sqlValue.getIntValue(); + final int sqlId = sqlValue.getIntValue(); final String sqlParam = sqlValue.getStringValue1(); - final List sqlMetaDataList = sqlMetaDataDao.getSqlMetaData(agentKey.getAgentId(), agentKey.getAgentStartTime(), hashCode); + final List 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 hashCode:" + hashCode); + api.setValue("SQL-ID not found sqlId:" + sqlId); annotationBoList.add(api); } else if (size == 1) { final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0); @@ -195,7 +187,7 @@ public void replacement(SpanAlign spanAlign, List annotationBoList // TODO need improvement AnnotationBo api = new AnnotationBo(); api.setKey(AnnotationKey.SQL.getCode()); - api.setValue(collisionSqlHashCodeMessage(hashCode, sqlMetaDataList)); + api.setValue(collisionSqlIdCodeMessage(sqlId, sqlMetaDataList)); annotationBoList.add(api); } // add if bindValue exists @@ -221,11 +213,11 @@ private AnnotationBo findAnnotation(List annotationBoList, int key return null; } - private String collisionSqlHashCodeMessage(int hashCode, List sqlMetaDataList) { + private String collisionSqlIdCodeMessage(int sqlId, List sqlMetaDataList) { // TODO need a separate test case to test for hashCode collision (probability way too low for easy replication) StringBuilder sb = new StringBuilder(64); - sb.append("Collision Sql hashCode:"); - sb.append(hashCode); + sb.append("Collision Sql sqlId:"); + sb.append(sqlId); sb.append('\n'); for (int i = 0; i < sqlMetaDataList.size(); i++) { if (i != 0) { @@ -242,10 +234,10 @@ private void transitionDynamicApiId(List spans) { this.transitionAnnotation(spans, new AnnotationReplacementCallback() { @Override public void replacement(SpanAlign spanAlign, List annotationBoList) { - final AgentKey key = getAgentKey(spanAlign); - final int apiId = getApiId(spanAlign); + + final int apiId = spanAlign.getApiId(); // may be able to get a more accurate data using agentIdentifier. - List apiMetaDataList = apiMetaDataDao.getApiMetaData(key.getAgentId(), key.getAgentStartTime(), apiId); + List apiMetaDataList = apiMetaDataDao.getApiMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), apiId); int size = apiMetaDataList.size(); if (size == 0) { AnnotationBo api = new AnnotationBo(); @@ -259,7 +251,7 @@ public void replacement(SpanAlign spanAlign, List annotationBoList apiMetaData.setValue(apiMetaDataBo); annotationBoList.add(apiMetaData); - if(apiMetaDataBo.getType() == 0) { + if (apiMetaDataBo.getType() == 0) { AnnotationBo apiAnnotation = new AnnotationBo(); apiAnnotation.setKey(AnnotationKey.API.getCode()); String apiInfo = getApiInfo(apiMetaDataBo); @@ -288,7 +280,7 @@ private void transitionCachedString(List spans) { this.transitionAnnotation(spans, new AnnotationReplacementCallback() { @Override public void replacement(SpanAlign spanAlign, List annotationBoList) { - final AgentKey key = getAgentKey(spanAlign); + List cachedStringAnnotation = findCachedStringAnnotation(annotationBoList); if (cachedStringAnnotation.isEmpty()) { return; @@ -296,10 +288,10 @@ public void replacement(SpanAlign spanAlign, List annotationBoList for (AnnotationBo annotationBo : cachedStringAnnotation) { final int cachedArgsKey = annotationBo.getKey(); int stringMetaDataId = (Integer) annotationBo.getValue(); - List stringMetaList = stringMetaDataDao.getStringMetaData(key.getAgentId(), key.getAgentStartTime(), stringMetaDataId); + List stringMetaList = stringMetaDataDao.getStringMetaData(spanAlign.getAgentId(), spanAlign.getAgentStartTime(), stringMetaDataId); int size = stringMetaList.size(); if (size == 0) { - logger.warn("StringMetaData not Found {}/{}/{}", key.getAgentId(), stringMetaDataId, key.getAgentStartTime()); + 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); @@ -334,20 +326,9 @@ private List findCachedStringAnnotation(List annotat private void transitionException(List spanAlignList) { for (SpanAlign spanAlign : spanAlignList) { - if (spanAlign.isSpan()) { - final SpanBo spanBo = spanAlign.getSpanBo(); - if (spanBo.hasException()) { - StringMetaDataBo stringMetaData = selectStringMetaData(spanBo.getAgentId(), spanBo.getExceptionId(), spanBo.getAgentStartTime()); - spanBo.setExceptionClass(stringMetaData.getStringValue()); - } - } else { - final SpanEventBo spanEventBo = spanAlign.getSpanEventBo(); - if (spanEventBo.hasException()) { - StringMetaDataBo stringMetaData = selectStringMetaData(spanEventBo.getAgentId(), spanEventBo.getExceptionId(), spanEventBo.getAgentStartTime()); - if (stringMetaData != null) { - spanEventBo.setExceptionClass(stringMetaData.getStringValue()); - } - } + if (spanAlign.hasException()) { + StringMetaDataBo stringMetaData = selectStringMetaData(spanAlign.getAgentId(), spanAlign.getExceptionId(), spanAlign.getAgentStartTime()); + spanAlign.setExceptionClass(stringMetaData.getStringValue()); } } @@ -369,26 +350,8 @@ private StringMetaDataBo selectStringMetaData(String agentId, int cacheId, long } } - private int getApiId(SpanAlign spanAlign) { - if (spanAlign.isSpan()) { - return spanAlign.getSpanBo().getApiId(); - } else { - return spanAlign.getSpanEventBo().getApiId(); - } - } - - private AgentKey getAgentKey(SpanAlign spanAlign) { - if (spanAlign.isSpan()) { - SpanBo spanBo = spanAlign.getSpanBo(); - return new AgentKey(spanBo.getAgentId(), spanBo.getAgentStartTime()); - } else { - final SpanEventBo spanEventBo = spanAlign.getSpanEventBo(); - return new AgentKey(spanEventBo.getAgentId(), spanEventBo.getAgentStartTime()); - } - } - private String collisionApiDidMessage(int apidId, List apiMetaDataList) { - // TODO need a separate test case to test for hashCode collision (probability way too low for easy replication) + // TODO need a separate test case to test for apidId collision (probability way too low for easy replication) StringBuilder sb = new StringBuilder(64); sb.append("Collision Api DynamicId:"); sb.append(apidId); @@ -426,31 +389,5 @@ private SpanResult order(List spans, long selectedSpanHint) { return new SpanResult(spanAligner.getMatchType(), callTree.iterator()); } - - private static final class AgentKey { - - private final String agentId; - private final long agentStartTime; - - private AgentKey(String agentId, long agentStartTime) { - if (agentId == null) { - throw new NullPointerException("agentId must not be null"); - } - this.agentId = agentId; - this.agentStartTime = agentStartTime; - } - - private String getAgentId() { - return agentId; - } - - private long getAgentStartTime() { - return agentStartTime; - } - } - - public void setSqlMetaDataDao(SqlMetaDataDao sqlMetaDataDao) { - this.sqlMetaDataDao = sqlMetaDataDao; - } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/TransactionInfoServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/TransactionInfoServiceImpl.java index 82fd2a1a3189..001fd94ed32f 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/TransactionInfoServiceImpl.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/TransactionInfoServiceImpl.java @@ -23,7 +23,6 @@ import com.navercorp.pinpoint.common.server.bo.AnnotationBo; import com.navercorp.pinpoint.common.server.bo.Event; import com.navercorp.pinpoint.common.server.bo.SpanBo; -import com.navercorp.pinpoint.common.server.bo.SpanEventBo; import com.navercorp.pinpoint.common.service.AnnotationKeyRegistryService; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; import com.navercorp.pinpoint.common.trace.AnnotationKeyMatcher; @@ -133,17 +132,17 @@ public RecordSet createRecordSet(CallTreeIterator callTreeIterator, long focusTi RecordSet recordSet = new RecordSet(); final List spanAlignList = callTreeIterator.values(); - // finds and marks the focusTimestamp. + // 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. - SpanBo focusTimeSpanBo = findFocusTimeSpanBo(spanAlignList, focusTimestamp); + SpanAlign viewPointSpanAlign = findViewPoint(spanAlignList, focusTimestamp); // FIXME patched temporarily for cases where focusTimeSpanBo is not found. Need a more complete solution. - if (focusTimeSpanBo != null) { - recordSet.setAgentId(focusTimeSpanBo.getAgentId()); - recordSet.setApplicationId(focusTimeSpanBo.getApplicationId()); + if (viewPointSpanAlign != null) { + recordSet.setAgentId(viewPointSpanAlign.getAgentId()); + recordSet.setApplicationId(viewPointSpanAlign.getApplicationId()); - final String applicationName = getRpcArgument(focusTimeSpanBo); + final String applicationName = getRpcArgument(viewPointSpanAlign); recordSet.setApplicationName(applicationName); } @@ -161,11 +160,11 @@ public RecordSet createRecordSet(CallTreeIterator callTreeIterator, long focusTi List recordList = spanAlignPopulate.populateSpanRecord(callTreeIterator); logger.debug("RecordList:{}", recordList); - if (focusTimeSpanBo != null) { + if (viewPointSpanAlign != null) { // mark the record to be used as focus - long beginTimeStamp = focusTimeSpanBo.getStartTime(); + long beginTimeStamp = viewPointSpanAlign.getStartTime(); - markFocusRecord(recordList, focusTimeSpanBo); + markFocusRecord(recordList, viewPointSpanAlign); recordSet.setBeginTimestamp(beginTimeStamp); } @@ -177,7 +176,7 @@ public RecordSet createRecordSet(CallTreeIterator callTreeIterator, long focusTi private boolean findIsLoggingTransactionInfo(List spanAlignList) { for (SpanAlign spanAlign : spanAlignList) { if (spanAlign.isSpan()) { - if (spanAlign.getSpanBo().getLoggingTransactionInfo() == LoggingInfo.LOGGED.getCode()) { + if (spanAlign.getLoggingTransactionInfo() == LoggingInfo.LOGGED.getCode()) { return true; } } @@ -186,9 +185,9 @@ private boolean findIsLoggingTransactionInfo(List spanAlignList) { return false; } - private void markFocusRecord(List recordList, final SpanBo focusTimeSpanBo) { + private void markFocusRecord(List recordList, final SpanAlign viewPointTimeSpanAlign) { for (Record record : recordList) { - if (focusTimeSpanBo.getSpanId() == record.getSpanId() && record.getBegin() == focusTimeSpanBo.getStartTime()) { + if (viewPointTimeSpanAlign.getSpanId() == record.getSpanId() && record.getBegin() == viewPointTimeSpanAlign.getStartTime()) { record.setFocused(true); break; } @@ -224,13 +223,7 @@ private long getStartTime(List spanAlignList) { return 0; } SpanAlign spanAlign = spanAlignList.get(0); - if (spanAlign.isSpan()) { - SpanBo spanBo = spanAlign.getSpanBo(); - return spanBo.getStartTime(); - } else { - SpanEventBo spanEventBo = spanAlign.getSpanEventBo(); - return spanAlign.getSpanBo().getStartTime() + spanEventBo.getStartElapsed(); - } + return spanAlign.getStartTime(); } private long getEndTime(List spanAlignList) { @@ -238,27 +231,18 @@ private long getEndTime(List spanAlignList) { return 0; } SpanAlign spanAlign = spanAlignList.get(0); - if (spanAlign.isSpan()) { - SpanBo spanBo = spanAlign.getSpanBo(); - return spanBo.getElapsed(); - } else { - SpanEventBo spanEventBo = spanAlign.getSpanEventBo(); - long begin = spanAlign.getSpanBo().getStartTime() + spanEventBo.getStartElapsed(); - long elapsed = spanEventBo.getEndElapsed(); - return begin + elapsed; - } + return spanAlign.getLastTime(); } - private SpanBo findFocusTimeSpanBo(List spanAlignList, long focusTimestamp) { - SpanBo firstSpan = null; + private SpanAlign findViewPoint(List spanAlignList, long focusTimestamp) { + SpanAlign firstSpan = null; for (SpanAlign spanAlign : spanAlignList) { if (spanAlign.isSpan()) { - SpanBo spanBo = spanAlign.getSpanBo(); - if (spanBo.getCollectorAcceptTime() == focusTimestamp) { - return spanBo; + if (spanAlign.getCollectorAcceptTime() == focusTimestamp) { + return spanAlign; } if (firstSpan == null) { - firstSpan = spanBo; + firstSpan = spanAlign; } } }; @@ -266,15 +250,16 @@ private SpanBo findFocusTimeSpanBo(List spanAlignList, long focusTime return firstSpan; } - private String getArgument(final SpanAlign align) { - if(align.isSpan()) { - return getRpcArgument(align.getSpanBo()); + private String getArgument(final SpanAlign spanAlign) { + if (spanAlign.isSpan()) { + return getRpcArgument(spanAlign); } - return getDisplayArgument(align.getSpanEventBo()); + return getDisplayArgument(spanAlign.getSpanEventBo()); } - private String getRpcArgument(SpanBo spanBo) { + private String getRpcArgument(SpanAlign spanAlign) { + SpanBo spanBo = spanAlign.getSpanBo(); String rpc = spanBo.getRpc(); if (rpc != null) { return rpc; @@ -347,7 +332,7 @@ private List populateSpanRecord(CallTreeIterator callTreeIterator) { recordList.add(record); // add exception record. - if(align.hasException()) { + if (align.hasException()) { final Record exceptionRecord = factory.getException(record.getTab() + 1, record.getId(), align); if(exceptionRecord != null) { recordList.add(exceptionRecord); @@ -356,7 +341,7 @@ private List populateSpanRecord(CallTreeIterator callTreeIterator) { // add annotation record. - if(!align.getAnnotationBoList().isEmpty()) { + if (!align.getAnnotationBoList().isEmpty()) { final List annotations = factory.getAnnotations(record.getTab() + 1, record.getId(), align); recordList.addAll(annotations); } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactory.java index ac957997575f..2b690a460bf0 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactory.java @@ -70,7 +70,7 @@ public Record get(final CallTreeNode node, final String argument) { align.getApplicationId(), registry.findServiceType(align.getServiceType()), align.getDestinationId(), - align.isHasChild(), + align.hasChild(), false, align.getTransactionId(), align.getSpanId(),