From 425096aa8b6003f5a56221b041845c5329364d19 Mon Sep 17 00:00:00 2001 From: seoyoung-park Date: Mon, 27 Nov 2023 18:04:15 +0900 Subject: [PATCH] [#9631] Add ApplicationServiceType in /transactionInfo --- .../pinpoint/web/calltree/span/Align.java | 2 + .../pinpoint/web/calltree/span/SpanAlign.java | 5 + .../web/calltree/span/SpanEventAlign.java | 5 + .../service/TransactionInfoServiceImpl.java | 2 +- .../TransactionInfoCallStackSerializer.java | 2 + .../web/view/TransactionInfoViewModel.java | 16 ++- .../web/vo/callstacks/AnnotationRecord.java | 4 +- .../web/vo/callstacks/BaseRecord.java | 107 ++++++++---------- .../web/vo/callstacks/DefaultRecord.java | 14 +-- .../web/vo/callstacks/ExceptionRecord.java | 27 ++++- .../pinpoint/web/vo/callstacks/Record.java | 4 + .../web/vo/callstacks/RecordFactory.java | 11 +- .../pinpoint/web/vo/callstacks/RecordSet.java | 2 +- .../web/vo/callstacks/RecordFactoryTest.java | 4 +- 14 files changed, 131 insertions(+), 74 deletions(-) diff --git a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/Align.java b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/Align.java index b58252492a68..a3878036a3fc 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/Align.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/Align.java @@ -72,6 +72,8 @@ public interface Align { String getApplicationId(); + Short getApplicationServiceType(); + long getAgentStartTime(); short getServiceType(); 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 894a5fa31b38..623e8e3e00b4 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 @@ -194,6 +194,11 @@ public String getApplicationId() { return spanBo.getApplicationId(); } + @Override + public Short getApplicationServiceType() { + return spanBo.getApplicationServiceType(); + } + @Override public long getAgentStartTime() { return spanBo.getAgentStartTime(); diff --git a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanEventAlign.java b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanEventAlign.java index 06b289d73d16..56ab11f2ece3 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanEventAlign.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/calltree/span/SpanEventAlign.java @@ -158,6 +158,11 @@ public String getApplicationId() { return spanBo.getApplicationId(); } + @Override + public Short getApplicationServiceType() { + return spanBo.getApplicationServiceType(); + } + @Override public long getAgentStartTime() { return spanBo.getAgentStartTime(); 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 f639f6034663..e86f4660fd72 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 @@ -160,7 +160,7 @@ public RecordSet createRecordSet(CallTreeIterator callTreeIterator, Predicate MAP = Collections.unmodifiableMap(toNameOrdinalMap()); @@ -231,6 +233,7 @@ public static class CallStack { private long end; private boolean excludeFromTimeline; private String applicationName = ""; + private String applicationServiceType = ""; private int tab; private String id = ""; private String parentId = ""; @@ -250,6 +253,7 @@ public static class CallStack { private String agentName = ""; private boolean isFocused; private boolean hasException; + private String exceptionChainId = ""; private boolean isAuthorized; private int lineNumber; private String location = ""; @@ -259,6 +263,7 @@ public CallStack(final Record record, long barRatio) { end = record.getBegin() + record.getElapsed(); excludeFromTimeline = record.isExcludeFromTimeline(); applicationName = record.getApplicationName(); + applicationServiceType = record.getApplicationServiceType(); tab = record.getTab(); id = String.valueOf(record.getId()); if (record.getParentId() > 0) { @@ -282,6 +287,7 @@ public CallStack(final Record record, long barRatio) { agentName = record.getAgentName(); isFocused = record.isFocused(); hasException = record.getHasException(); + exceptionChainId = String.valueOf(record.getExceptionChainId()); isAuthorized = record.isAuthorized(); lineNumber = record.getLineNumber(); location = record.getLocation(); @@ -307,6 +313,10 @@ public String getApplicationName() { return applicationName; } + public String getApplicationServiceType() { + return applicationServiceType; + } + public int getTab() { return tab; } @@ -383,6 +393,10 @@ public boolean isHasException() { return hasException; } + public String getExceptionChainId() { + return exceptionChainId; + } + public boolean isAuthorized() { return isAuthorized; } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/AnnotationRecord.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/AnnotationRecord.java index f6c26411bc8e..184d61ae012c 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/AnnotationRecord.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/AnnotationRecord.java @@ -20,7 +20,9 @@ * @author jaehong.kim */ public class AnnotationRecord extends BaseRecord { - public AnnotationRecord(final int tab, final int id, final int parentId, final String title, final String arguments, final boolean authorized) { + public AnnotationRecord( + final int tab, final int id, final int parentId, final String title, final String arguments, final boolean authorized + ) { this.tab = tab; this.id = id; this.parentId = parentId; diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/BaseRecord.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/BaseRecord.java index e633a240a9ea..713cd9c93d9a 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/BaseRecord.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/BaseRecord.java @@ -35,10 +35,12 @@ public abstract class BaseRecord implements Record { protected String agentId; protected String agentName; protected String applicationName; - protected ServiceType serviceType; + protected ServiceType applicationServiceType; + protected ServiceType apiServiceType; protected String destinationId; protected boolean hasChild; protected boolean hasException; + protected long exceptionChainId; protected String transactionId; protected long spanId; protected long executionMilliseconds; @@ -109,18 +111,25 @@ public String getApplicationName() { return applicationName; } + public String getApplicationServiceType() { + if (applicationServiceType == null) { + return ""; + } + return applicationServiceType.getName(); + } + public String getApiType() { if (destinationId == null) { - if (serviceType == null) { + if (apiServiceType == null) { // no ServiceType when parameter return ""; } - return serviceType.getDesc(); + return apiServiceType.getDesc(); } - if (serviceType.isIncludeDestinationId()) { - return serviceType.getDesc() + "(" + destinationId + ")"; + if (apiServiceType.isIncludeDestinationId()) { + return apiServiceType.getDesc() + "(" + destinationId + ")"; } else { - return serviceType.getDesc(); + return apiServiceType.getDesc(); } } @@ -161,6 +170,10 @@ public boolean getHasException() { return hasException; } + public long getExceptionChainId() { + return exceptionChainId; + } + public String getTransactionId() { return transactionId; } @@ -191,56 +204,36 @@ public String getLocation() { @Override public String toString() { - return "{tab=" + - tab + - ", id=" + - id + - ", parentId=" + - parentId + - ", method=" + - method + - ", title=" + - title + - ", simpleClassName=" + - simpleClassName + - ", fullApiDescription=" + - fullApiDescription + - ", arguments=" + - arguments + - ", begin=" + - begin + - ", elapsed=" + - elapsed + - ", gap=" + - gap + - ", executionMilliseconds=" + - executionMilliseconds + - ", agentId=" + - agentId + - ", agentName=" + - agentName + - ", applicationName=" + - applicationName + - ", serviceType=" + - serviceType + - ", destinationId=" + - destinationId + - ", excludeFromTimeline=" + - excludeFromTimeline + - ", transactionId=" + - transactionId + - ", spanId=" + - spanId + - ", focused=" + - focused + - ", hasChild=" + - hasChild + - ", hasException=" + - hasException + - ", methodTypeEnum=" + - methodTypeEnum + - ", isAuthorized=" + - isAuthorized + - "}"; + return "BaseRecord{" + + "tab=" + tab + + ", id=" + id + + ", parentId=" + parentId + + ", method=" + method + + ", title='" + title + '\'' + + ", arguments='" + arguments + '\'' + + ", begin=" + begin + + ", elapsed=" + elapsed + + ", gap=" + gap + + ", agentId='" + agentId + '\'' + + ", agentName='" + agentName + '\'' + + ", applicationName='" + applicationName + '\'' + + ", applicationServiceType=" + applicationServiceType + + ", apiServiceType=" + apiServiceType + + ", destinationId='" + destinationId + '\'' + + ", hasChild=" + hasChild + + ", hasException=" + hasException + + ", exceptionChainId=" + exceptionChainId + + ", transactionId='" + transactionId + '\'' + + ", spanId=" + spanId + + ", executionMilliseconds=" + executionMilliseconds + + ", methodTypeEnum=" + methodTypeEnum + + ", isAuthorized=" + isAuthorized + + ", excludeFromTimeline=" + excludeFromTimeline + + ", focused=" + focused + + ", simpleClassName='" + simpleClassName + '\'' + + ", fullApiDescription='" + fullApiDescription + '\'' + + ", lineNumber=" + lineNumber + + ", location='" + location + '\'' + + '}'; } } \ No newline at end of file diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/DefaultRecord.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/DefaultRecord.java index 1dbe55e3b072..386eaf80fa52 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/DefaultRecord.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/DefaultRecord.java @@ -41,7 +41,7 @@ public DefaultRecord(int tab, int id, int parentId, boolean method, String title this.agentName = agentName; this.applicationName = applicationName; - this.serviceType = serviceType; + this.apiServiceType = serviceType; this.destinationId = destinationId; this.excludeFromTimeline = serviceType == null || serviceType.isInternalMethod(); @@ -112,16 +112,16 @@ public String getApplicationName() { public String getApiType() { if (destinationId == null) { - if (serviceType == null) { + if (apiServiceType == null) { // no ServiceType when parameter return ""; } - return serviceType.getDesc(); + return apiServiceType.getDesc(); } - if (serviceType.isIncludeDestinationId()) { - return serviceType.getDesc() + "(" + destinationId + ")"; + if (apiServiceType.isIncludeDestinationId()) { + return apiServiceType.getDesc() + "(" + destinationId + ")"; } else { - return serviceType.getDesc(); + return apiServiceType.getDesc(); } } @@ -221,7 +221,7 @@ public String toString() { ", applicationName=" + applicationName + ", serviceType=" + - serviceType + + apiServiceType + ", destinationId=" + destinationId + ", excludeFromTimeline=" + diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/ExceptionRecord.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/ExceptionRecord.java index 3511c63262d6..17aabd783767 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/ExceptionRecord.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/ExceptionRecord.java @@ -16,22 +16,34 @@ package com.navercorp.pinpoint.web.vo.callstacks; +import com.navercorp.pinpoint.common.server.bo.AnnotationBo; +import com.navercorp.pinpoint.common.trace.AnnotationKey; +import com.navercorp.pinpoint.common.trace.ServiceType; import com.navercorp.pinpoint.web.calltree.span.Align; import org.apache.commons.lang3.StringUtils; +import java.util.List; + /** * @author jaehong.kim */ public class ExceptionRecord extends BaseRecord { - public ExceptionRecord(final int tab, final int id, final int parentId, final Align align) { + public ExceptionRecord( + final int tab, final int id, final int parentId, final Align align, + ServiceType applicationServiceType + ) { this.tab = tab; this.id = id; this.parentId = parentId; this.title = toSimpleExceptionName(align.getExceptionClass()); this.arguments = buildArgument(align.getExceptionMessage()); this.isAuthorized = true; - this.hasException = align.isSpan() ? false : true; + this.hasException = !align.isSpan(); + this.agentId = align.getAgentId(); + this.applicationName = align.getApplicationId(); + this.applicationServiceType = applicationServiceType; + this.exceptionChainId = toExceptionChainId(align.getAnnotationBoList()); } String toSimpleExceptionName(String exceptionClass) { @@ -45,6 +57,17 @@ String toSimpleExceptionName(String exceptionClass) { return exceptionClass; } + long toExceptionChainId(List annotationBoList) { + for (AnnotationBo annotationBo : annotationBoList) { + if (annotationBo.getKey() == AnnotationKey.EXCEPTION_LINK_ID.getCode() + && annotationBo.getValue() instanceof Long + ) { + return (long) annotationBo.getValue(); + } + } + return -1; + } + String buildArgument(String exceptionMessage) { return StringUtils.defaultString(exceptionMessage, ""); } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/Record.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/Record.java index 6f3b85227286..00a3050860f0 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/Record.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/Record.java @@ -53,6 +53,8 @@ public interface Record { String getApplicationName(); + String getApplicationServiceType(); + String getApiType(); boolean isExcludeFromTimeline(); @@ -73,6 +75,8 @@ public interface Record { boolean getHasException(); + long getExceptionChainId(); + String getTransactionId(); long getSpanId(); 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 607956f75631..9a0cabfc1c1d 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 @@ -178,7 +178,12 @@ public Record getException(final int depth, final int parentId, final Align alig if (!align.hasException()) { return null; } - return new ExceptionRecord(depth, getNextId(), parentId, align); + return new ExceptionRecord( + depth, getNextId(), parentId, align, + registry.findServiceType( + align.getApplicationServiceType() + ) + ); } public List getAnnotations(final int depth, final int parentId, Align align) { @@ -188,7 +193,9 @@ public List getAnnotations(final int depth, final int parentId, Align al if (key.isViewInRecordSet()) { final String title = this.annotationRecordFormatter.formatTitle(key, annotation, align); final String arguments = this.annotationRecordFormatter.formatArguments(key, annotation, align); - final Record record = new AnnotationRecord(depth, getNextId(), parentId, title, arguments, annotation.isAuthorized()); + final Record record = new AnnotationRecord( + depth, getNextId(), parentId, title, arguments, annotation.isAuthorized() + ); list.add(record); } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordSet.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordSet.java index 268a56edae47..efa312725e8a 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordSet.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/callstacks/RecordSet.java @@ -29,6 +29,7 @@ public class RecordSet { private List recordList; private String applicationName; + private String applicationServiceType; private long beginTimestamp; private String agentId; @@ -88,7 +89,6 @@ public long getBeginTimestamp() { return beginTimestamp; } - public String getAgentId() { return agentId; } 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 755f7be6a169..c7bb0573cac3 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 @@ -348,10 +348,10 @@ public void testMakeRecord() { assertThat(actuals.getEndTime()).isEqualTo(1670305848583L); List recordActuals = actuals.getRecordList(); Record recordActual = recordActuals.get(0); - assertThat(recordActual).extracting("tab", "id", "parentId", "method", "title", "arguments", "begin", "elapsed", "gap", "agentId", "agentName", "applicationName", "serviceType", "destinationId", "hasChild", "hasException", "spanId", "executionMilliseconds", "methodTypeEnum", "isAuthorized", "excludeFromTimeline", "focused", "simpleClassName", "fullApiDescription", "lineNumber", "location") + assertThat(recordActual).extracting("tab", "id", "parentId", "method", "title", "arguments", "begin", "elapsed", "gap", "agentId", "agentName", "applicationName", "apiServiceType", "destinationId", "hasChild", "hasException", "spanId", "executionMilliseconds", "methodTypeEnum", "isAuthorized", "excludeFromTimeline", "focused", "simpleClassName", "fullApiDescription", "lineNumber", "location") .contains(0, 1, 0, true, "Node Server Process", "/", 1670305848569L, 14L, 0, "express-node-sample-id", " ", "express-node-sample-name", null, null, true, false, 8174884636707391L, 13L, MethodTypeEnum.WEB_REQUEST, true, true, true, "", "Node Server Process", 0, ""); recordActual = recordActuals.get(4); - assertThat(recordActual).extracting("tab", "id", "parentId", "method", "title", "arguments", "begin", "elapsed", "gap", "agentId", "agentName", "applicationName", "serviceType", "destinationId", "hasChild", "hasException", "spanId", "executionMilliseconds", "methodTypeEnum", "isAuthorized", "excludeFromTimeline", "focused", "simpleClassName", "fullApiDescription", "lineNumber", "location") + assertThat(recordActual).extracting("tab", "id", "parentId", "method", "title", "arguments", "begin", "elapsed", "gap", "agentId", "agentName", "applicationName", "apiServiceType", "destinationId", "hasChild", "hasException", "spanId", "executionMilliseconds", "methodTypeEnum", "isAuthorized", "excludeFromTimeline", "focused", "simpleClassName", "fullApiDescription", "lineNumber", "location") .contains(1, 5, 1, true, "use(logger)", "", 1670305848569L, 1L, 0L, "express-node-sample-id", "", "express-node-sample-name", null, "localhost:3000", false, false, 8174884636707391L, 1L, MethodTypeEnum.DEFAULT, true, true, false, "Function", "express.Function.use(logger)", 42, "/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/app.js"); } } \ No newline at end of file