diff --git a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CallTreeNode.java b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CallTreeNode.java index 2cb5f735921c..161edb61cf62 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CallTreeNode.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/CallTreeNode.java @@ -113,4 +113,53 @@ public String toString() { builder.append("}"); return builder.toString(); } + + public static class Builder { + private CallTreeNode.Builder parent; + private CallTreeNode.Builder child; + private CallTreeNode.Builder sibling; + private final Align align; + private CallTreeNode node; + + public Builder(Align align) { + this.align = align; + } + + public Builder setParent(CallTreeNode.Builder parent) { + this.parent = parent; + return this; + } + + public Builder setChild(CallTreeNode.Builder child) { + this.child = child; + return this; + } + + public Builder setSibling(CallTreeNode.Builder sibling) { + this.sibling = sibling; + return this; + } + + public CallTreeNode build() { + if (this.node != null) { + return this.node; + } + + this.node = new CallTreeNode(getCallTreeNode(this.parent), this.align); + this.node.child = getCallTreeNode(this.child); + this.node.sibling = getCallTreeNode(this.sibling); + return this.node; + } + + private CallTreeNode getCallTreeNode(CallTreeNode.Builder builder) { + if (builder == null) { + return null; + } + + if (builder.node == null) { + builder.node = builder.build(); + } + return builder.node; + } + } } \ No newline at end of file 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 5fccf1d40a5a..9dd934df89b9 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 @@ -286,4 +286,16 @@ public String toString() { ", executionMilliseconds=" + executionMilliseconds + '}'; } + + public static class Builder { + private final SpanBo spanBo; + + public Builder(SpanBo spanBo) { + this.spanBo = spanBo; + } + + public SpanAlign build() { + return new SpanAlign(this.spanBo); + } + } } \ No newline at end of file diff --git a/web/src/test/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactoryTest.java b/web/src/test/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactoryTest.java index 35962aa66ce8..7952cbde3192 100644 --- a/web/src/test/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactoryTest.java +++ b/web/src/test/java/com/navercorp/pinpoint/web/vo/callstacks/RecordFactoryTest.java @@ -18,23 +18,26 @@ import com.navercorp.pinpoint.common.profiler.util.TransactionId; import com.navercorp.pinpoint.common.server.bo.SpanBo; +import com.navercorp.pinpoint.common.server.bo.SpanEventBo; import com.navercorp.pinpoint.common.server.trace.ApiParserProvider; import com.navercorp.pinpoint.loader.service.AnnotationKeyRegistryService; import com.navercorp.pinpoint.loader.service.ServiceTypeRegistryService; -import com.navercorp.pinpoint.web.calltree.span.Align; -import com.navercorp.pinpoint.web.calltree.span.CallTreeIterator; -import com.navercorp.pinpoint.web.calltree.span.CallTreeNode; -import com.navercorp.pinpoint.web.calltree.span.SpanAlign; -import com.navercorp.pinpoint.web.service.AnnotationKeyMatcherService; -import com.navercorp.pinpoint.web.service.ProxyRequestTypeRegistryService; -import com.navercorp.pinpoint.web.service.RecorderFactoryProvider; +import com.navercorp.pinpoint.web.calltree.span.*; +import com.navercorp.pinpoint.web.dao.TraceDao; +import com.navercorp.pinpoint.web.service.*; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import java.time.Instant; +import java.util.Optional; +import java.util.function.Predicate; + import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author Woonduk Kang(emeroad) @@ -93,24 +96,71 @@ public void getParameter_check_argument() { Assertions.assertEquals(exceptionRecord.getArguments(), "null"); } - // 0 = {CallTreeNode@12622} "{depth=0, child=true, sibling=false, align=SpanAlign{spanBo=5997054625569493, hasChild=true, meta=false, id=1, gap=0, depth=0, executionMilliseconds=574}}" - // 1 = {CallTreeNode@14600} "{depth=1, child=false, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=0, startElapsed=4, endElapsed=3, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=17, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=17, apiInfo='express.Function.use(logger)', lineNumber=42, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(logger):42, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=4, depth=1, executionMilliseconds=3}}" - // 2 = {CallTreeNode@14601} "{depth=1, child=false, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=1, startElapsed=7, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=18, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=18, apiInfo='express.Function.use(jsonParser)', lineNumber=43, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(jsonParser):43, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=1, executionMilliseconds=0}}" - // 3 = {CallTreeNode@14602} "{depth=1, child=false, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=2, startElapsed=7, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=19, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=19, apiInfo='express.Function.use(urlencodedParser)', lineNumber=44, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(urlencodedParser):44, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=1, executionMilliseconds=0}}" - // 4 = {CallTreeNode@14603} "{depth=1, child=false, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=3, startElapsed=7, endElapsed=1, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=20, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=20, apiInfo='express.Function.use(cookieParser)', lineNumber=45, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(cookieParser):45, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=1, executionMilliseconds=1}}" - // 5 = {CallTreeNode@14604} "{depth=1, child=false, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=4, startElapsed=8, endElapsed=2, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=21, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=21, apiInfo='express.Function.use(serveStatic)', lineNumber=46, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(serveStatic):46, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=1, executionMilliseconds=2}}" - // 6 = {CallTreeNode@14605} "{depth=1, child=true, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=5, startElapsed=12, endElapsed=4, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=11, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=11, apiInfo='express.Function.proto.get(path, callback)', lineNumber=24, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.proto.get(path, callback):24, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=2, depth=1, executionMilliseconds=4}}" - // 7 = {CallTreeNode@14606} "{depth=2, child=true, sibling=true, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=6, startElapsed=13, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669747061820, apiId=0, apiInfo='redis.set.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=1}, id=0, gap=1, depth=2, executionMilliseconds=0}}" - // 8 = {CallTreeNode@14607} "{depth=3, child=true, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=3, executionMilliseconds=0}}" - // 9 = {CallTreeNode@14608} "{depth=4, child=false, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669747061820, apiId=0, apiInfo='redis.set.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=8082279540288497, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=4, executionMilliseconds=0}}" - // 10 = {CallTreeNode@14609} "{depth=2, child=true, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=7, startElapsed=14, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669747061821, apiId=0, apiInfo='redis.get.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=2}, id=0, gap=1, depth=2, executionMilliseconds=0}}" - // 11 = {CallTreeNode@14610} "{depth=3, child=true, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669746947722, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=3, executionMilliseconds=0}}" - // 12 = {CallTreeNode@14611} "{depth=4, child=false, sibling=false, align=SpanEventAlign{spanBo=5997054625569493, spanEventBo={version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669747061821, apiId=0, apiInfo='redis.get.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=7264920545515817, hasException=false, exceptionClass=null, nextAsyncId=0}, id=0, gap=0, depth=4, executionMilliseconds=0}}" + // 0 = {parent = null, child = 1 reference, sibling = null + // , align = SpanAlign{ + // spanBo = SpanBo { version=1, agentId='express-node-sample-id', agentName='', applicationId='express-node-sample-name', agentStartTime=1670293953108 + // , transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30} + // , spanId=8174884636707391, parentSpanId=-1, parentApplicationId='null', parentApplicationServiceType=0, startTime=1670305848569 + // , elapsed=14, rpc='/', serviceType=1400, endPoint='localhost:3000', apiId=1 + // , annotationBoList=[AnnotationBo{key=46, value=200, isAuthorized=true} + // , AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id' + // , startTime=1670293953108, apiId=1, apiInfo='Node Server Process' + // , lineNumber=0, methodTypeEnum=WEB_REQUEST, location='null'}, isAuthorized=true} + // , AnnotationBo{key=10015, value=Node Server Process, isAuthorized=true}] + // , flag=0, errCode=0 + // , spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=1, serviceType=6600 + // , destinationId=localhost:3000, endPoint=localhost:3000, apiId=17 + // , annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true} + // , AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=17, apiInfo='express.Function.use(logger)', lineNumber=42, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true} + // , AnnotationBo{key=12, value=express.Function.use(logger):42, isAuthorized=true}] + // , depth=1, nextSpanId=-1, hasException=false, exceptionClass=null + // , nextAsyncId=0} + // , {version=0, sequence=1, startElapsed=1, endElapsed=0, serviceType=6600 + // , destinationId=localhost:3000, endPoint=localhost:3000, apiId=18 + // , annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true} + // , AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=18, apiInfo='express.Function.use(jsonParser)', lineNumber=43, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true} + // , AnnotationBo{key=12, value=express.Function.use(jsonParser):43, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0} + // , {version=0, sequence=2, startElapsed=1, endElapsed=0, serviceType=6600 + // , destinationId=localhost:3000, endPoint=localhost:3000, apiId=19 + // , annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true} + // , AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=19, apiInfo='express.Function.use(urlencodedParser)', lineNumber=44, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true} + // , AnnotationBo{key=12, value=express.Function.use(urlencodedParser):44, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0} + // , {version=0, sequence=3, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=20, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=20, apiInfo='express.Function.use(cookieParser)', lineNumber=45, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(cookieParser):45, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=4, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=21, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=21, apiInfo='express.Function.use(serveStatic)', lineNumber=46, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(serveStatic):46, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=5, startElapsed=1, endElapsed=1, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=11, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=11, apiInfo='express.Function.proto.get(path, callback)', lineNumber=24, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.proto.get(path, callback):24, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=6, startElapsed=1, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.set.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=57}, {version=0, sequence=7, startElapsed=1, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.get.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=58}], spanChunkBoList=[SpanChunkBo{version=1, agentId='express-node-sample-id', applicationId='express-node-sample-name', agentStartTime=1670293953108, transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30}, spanId=8174884636707391, endPoint='null', serviceType=0, applicationServiceType=null, spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.set.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=8204265135595103, hasException=false, exceptionClass=null, nextAsyncId=0}], collectorAcceptTime=1670305848574, localAsyncId=LocalAsyncIdBo{asyncId=57, sequence=0}, keyTIme=1670305848570}, SpanChunkBo{version=1, agentId='express-node-sample-id', applicationId='express-node-sample-name', agentStartTime=1670293953108, transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30}, spanId=8174884636707391, endPoint='null', serviceType=0, applicationServiceType=null, spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.get.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=1376599456185043, hasException=false, exceptionClass=null, nextAsyncId=0}], collectorAcceptTime=1670305848574, localAsyncId=LocalAsyncIdBo{asyncId=58, sequence=0}, keyTIme=1670305848570}] + // , collectorAcceptTime=1670305848586, hasException=false, exceptionClass='null', applicationServiceType=1400, acceptorHost='null', remoteAddr='::1', loggingTransactionInfo=0 + // } + // , hasChild=true, meta=false, id=0, gap=0, depth=0, executionMilliseconds=12 + // } + // } + // 1 = {parent = 0 reference, child = null, sibling = 2 reference + // , align = SpanEventAlign{id = 0, gap = 0, depth = 1, executionMilliseconds = 1 + // , spanBo = SpanBo{version=1, agentId='express-node-sample-id', agentName='', applicationId='express-node-sample-name', agentStartTime=1670293953108, transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30}, spanId=8174884636707391, parentSpanId=-1, parentApplicationId='null', parentApplicationServiceType=0, startTime=1670305848569, elapsed=14, rpc='/', serviceType=1400, endPoint='localhost:3000', apiId=1, annotationBoList=[AnnotationBo{key=46, value=200, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=1, apiInfo='Node Server Process', lineNumber=0, methodTypeEnum=WEB_REQUEST, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Node Server Process, isAuthorized=true}], flag=0, errCode=0, spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=1, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=17, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=17, apiInfo='express.Function.use(logger)', lineNumber=42, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(logger):42, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=1, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=18, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=18, apiInfo='express.Function.use(jsonParser)', lineNumber=43, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(jsonParser):43, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=2, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=19, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=19, apiInfo='express.Function.use(urlencodedParser)', lineNumber=44, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(urlencodedParser):44, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=3, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=20, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=20, apiInfo='express.Function.use(cookieParser)', lineNumber=45, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(cookieParser):45, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=4, startElapsed=1, endElapsed=0, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=21, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=21, apiInfo='express.Function.use(serveStatic)', lineNumber=46, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(serveStatic):46, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=5, startElapsed=1, endElapsed=1, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=11, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=11, apiInfo='express.Function.proto.get(path, callback)', lineNumber=24, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.proto.get(path, callback):24, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=6, startElapsed=1, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.set.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=57}, {version=0, sequence=7, startElapsed=1, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.call, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.get.call', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=58}], spanChunkBoList=[SpanChunkBo{version=1, agentId='express-node-sample-id', applicationId='express-node-sample-name', agentStartTime=1670293953108, transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30}, spanId=8174884636707391, endPoint='null', serviceType=0, applicationServiceType=null, spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.set.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.set.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=8204265135595103, hasException=false, exceptionClass=null, nextAsyncId=0}], collectorAcceptTime=1670305848574, localAsyncId=LocalAsyncIdBo{asyncId=57, sequence=0}, keyTIme=1670305848570}, SpanChunkBo{version=1, agentId='express-node-sample-id', applicationId='express-node-sample-name', agentStartTime=1670293953108, transactionId=TransactionId{agentId='express-node-sample-id', agentStartTime=1670293953108, transactionSequence=30}, spanId=8174884636707391, endPoint='null', serviceType=0, applicationServiceType=null, spanEventBoList=[{version=0, sequence=0, startElapsed=0, endElapsed=0, serviceType=100, destinationId=null, endPoint=null, apiId=2, annotationBoList=[AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=2, apiInfo='Asynchronous Invocation', lineNumber=0, methodTypeEnum=INVOCATION, location='null'}, isAuthorized=true}, AnnotationBo{key=10015, value=Asynchronous Invocation, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}, {version=0, sequence=1, startElapsed=0, endElapsed=0, serviceType=8200, destinationId=Redis, endPoint=127.0.0.1:6379, apiId=0, annotationBoList=[AnnotationBo{key=12, value=redis.get.end, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670305848570, apiId=0, apiInfo='redis.get.end', lineNumber=0, methodTypeEnum=DEFAULT, location='null'}, isAuthorized=true}], depth=2, nextSpanId=1376599456185043, hasException=false, exceptionClass=null, nextAsyncId=0}], collectorAcceptTime=1670305848574, localAsyncId=LocalAsyncIdBo{asyncId=58, sequence=0}, keyTIme=1670305848570}], collectorAcceptTime=1670305848586, hasException=false, exceptionClass='null', applicationServiceType=1400, acceptorHost='null', remoteAddr='::1', loggingTransactionInfo=0}, spanEventBo = {version=0, sequence=0, startElapsed=0, endElapsed=1, serviceType=6600, destinationId=localhost:3000, endPoint=localhost:3000, apiId=17, annotationBoList=[AnnotationBo{key=-1, value=/, isAuthorized=true}, AnnotationBo{key=13, value=ApiMetaDataBo{agentId='express-node-sample-id', startTime=1670293953108, apiId=17, apiInfo='express.Function.use(logger)', lineNumber=42, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js'}, isAuthorized=true}, AnnotationBo{key=12, value=express.Function.use(logger):42, isAuthorized=true}], depth=1, nextSpanId=-1, hasException=false, exceptionClass=null, nextAsyncId=0}}}" @Test public void testMakeRecord() { - CallTreeNode root = new CallTreeNode(null, new SpanAlign(new SpanBo.Builder(5997054625569493L).build())); - root.setChild(new CallTreeNode(root, new SpanAlign(new SpanBo.Builder(5997054625569493L).build()))); - CallTreeIterator iterator = new CallTreeIterator(root); - assertThat(iterator.size()).isEqualTo(2); + SpanAlign rootAlign = new SpanAlign(new SpanBo.Builder(8174884636707391L).build()); + CallTreeNode.Builder root = new CallTreeNode.Builder(rootAlign); + + SpanEventAlign childAlign = new SpanEventAlign(new SpanBo.Builder(8174884636707391L).build(), new SpanEventBo()); + CallTreeNode.Builder child = new CallTreeNode.Builder(childAlign); + + root.setChild(child); + child.setParent(root); + + CallTreeIterator callTreeIterator = new CallTreeIterator(root.build()); + assertThat(callTreeIterator.size()).isEqualTo(2); + Instant now = Instant.now(); + Predicate spanMatchFilter = SpanFilters.spanFilter(5997054625569493L, "express-node-sample-id", now.toEpochMilli()); + + TraceDao mockedDao = mock(TraceDao.class); + AnnotationKeyMatcherService mockedAnnotationKeyMatcherService = mock(AnnotationKeyMatcherService.class); + RecorderFactoryProvider mockedProvider = mock(RecorderFactoryProvider.class); + TransactionInfoService dut = new TransactionInfoServiceImpl(mockedDao, mockedAnnotationKeyMatcherService, Optional.empty(), mockedProvider); + + ServiceTypeRegistryService mockedRegistry = mock(ServiceTypeRegistryService.class); + AnnotationKeyRegistryService mockedAnnotationKeyRegistryService = mock(AnnotationKeyRegistryService.class); + ProxyRequestTypeRegistryService mockedProxyRequestTypeRegistryService = mock(ProxyRequestTypeRegistryService.class); + ApiParserProvider mockedApiParserProvider = mock(ApiParserProvider.class); +// when(mockedProvider.getRecordFactory()).thenReturn(new RecordFactory(mockedAnnotationKeyMatcherService, mockedRegistry, mockedAnnotationKeyRegistryService, mockedProxyRequestTypeRegistryService, mockedApiParserProvider)); + +// RecordSet actuals = dut.createRecordSet(callTreeIterator, spanMatchFilter); } } \ No newline at end of file