Skip to content

Commit

Permalink
[#9631] Add ApplicationServiceType in /transactionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed Nov 27, 2023
1 parent bf9bfed commit 425096a
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public interface Align {

String getApplicationId();

Short getApplicationServiceType();

long getAgentStartTime();

short getServiceType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public String getApplicationId() {
return spanBo.getApplicationId();
}

@Override
public Short getApplicationServiceType() {
return spanBo.getApplicationServiceType();
}

@Override
public long getAgentStartTime() {
return spanBo.getAgentStartTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ public String getApplicationId() {
return spanBo.getApplicationId();
}

@Override
public Short getApplicationServiceType() {
return spanBo.getApplicationServiceType();
}

@Override
public long getAgentStartTime() {
return spanBo.getAgentStartTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public RecordSet createRecordSet(CallTreeIterator callTreeIterator, Predicate<Sp

if (rootEndTime - startTime <= 0) {
recordSet.setEndTime(endTime);
} else if ((double)(rootEndTime - startTime) / (endTime-startTime) < 0.1) {
} else if ((double) (rootEndTime - startTime) / (endTime - startTime) < 0.1) {
recordSet.setEndTime(rootEndTime);
} else {
recordSet.setEndTime(endTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void serialize(TransactionInfoViewModel.CallStack value, JsonGenerator jg
jgen.writeString(value.getAgentName());
jgen.writeNumber(value.getLineNumber());
jgen.writeString(value.getLocation());
jgen.writeString(value.getApplicationServiceType());
jgen.writeString(value.getExceptionChainId());
jgen.writeEndArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ enum Field {
isAuthorized,
agentName,
lineNumber,
location;
location,
applicationServiceType,
exceptionChainId;

private static final Map<String, Integer> MAP = Collections.unmodifiableMap(toNameOrdinalMap());

Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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) {
Expand All @@ -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();
Expand All @@ -307,6 +313,10 @@ public String getApplicationName() {
return applicationName;
}

public String getApplicationServiceType() {
return applicationServiceType;
}

public int getTab() {
return tab;
}
Expand Down Expand Up @@ -383,6 +393,10 @@ public boolean isHasException() {
return hasException;
}

public String getExceptionChainId() {
return exceptionChainId;
}

public boolean isAuthorized() {
return isAuthorized;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
Expand Down Expand Up @@ -161,6 +170,10 @@ public boolean getHasException() {
return hasException;
}

public long getExceptionChainId() {
return exceptionChainId;
}

public String getTransactionId() {
return transactionId;
}
Expand Down Expand Up @@ -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 + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

}
Expand Down Expand Up @@ -221,7 +221,7 @@ public String toString() {
", applicationName=" +
applicationName +
", serviceType=" +
serviceType +
apiServiceType +
", destinationId=" +
destinationId +
", excludeFromTimeline=" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -45,6 +57,17 @@ String toSimpleExceptionName(String exceptionClass) {
return exceptionClass;
}

long toExceptionChainId(List<AnnotationBo> 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, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public interface Record {

String getApplicationName();

String getApplicationServiceType();

String getApiType();

boolean isExcludeFromTimeline();
Expand All @@ -73,6 +75,8 @@ public interface Record {

boolean getHasException();

long getExceptionChainId();

String getTransactionId();

long getSpanId();
Expand Down
Loading

0 comments on commit 425096a

Please sign in to comment.