Skip to content

Commit

Permalink
[#9631] Move ExecuteQuery state to SpanEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jan 17, 2024
1 parent 447e328 commit 7ffa921
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class SpanEvent extends DefaultFrameAttachment {

private AsyncId asyncIdObject;

private boolean executeQueryType;

public SpanEvent() {
}

Expand Down Expand Up @@ -204,6 +206,14 @@ public AsyncId getAsyncIdObject() {
return asyncIdObject;
}

public void setExecuteQueryType(boolean executeQueryType) {
this.executeQueryType = executeQueryType;
}

public boolean isExecuteQueryType() {
return executeQueryType;
}

@Override
public String toString() {
return "SpanEvent{" +
Expand All @@ -221,6 +231,7 @@ public String toString() {
", destinationId='" + destinationId + '\'' +
", apiId=" + apiId +
", exceptionInfo=" + exceptionInfo +
", executeQueryType=" + executeQueryType +
"} ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public class WrappedSpanEventRecorder extends AbstractRecorder implements SpanEv

private ExceptionContext exceptionContext;

private DatabaseInfo databaseInfo;

public WrappedSpanEventRecorder(TraceRoot traceRoot,
AsyncContextFactory asyncContextFactory,
StringMetaDataService stringMetaDataService,
Expand Down Expand Up @@ -89,7 +87,6 @@ public WrappedSpanEventRecorder(TraceRoot traceRoot,
public void setWrapped(final SpanEvent spanEvent, ExceptionContext exceptionContext) {
this.spanEvent = spanEvent;
this.exceptionContext = exceptionContext;
this.databaseInfo = null;
}

@Override
Expand All @@ -116,14 +113,14 @@ public void recordSqlParsingResult(ParsingResult parsingResult, String bindValue
Annotation<?> sqlAnnotation = this.sqlMetaDataService.newSqlAnnotation(parsingResult, bindValue);
spanEvent.addAnnotation(sqlAnnotation);

if (databaseInfo != null && spanEvent.getServiceType() == databaseInfo.getExecuteQueryType().getCode()) {
if (spanEvent.isExecuteQueryType()) {
sqlCountService.recordSqlCount(this.traceRoot);
}
}

@Override
public void recordDatabaseInfo(DatabaseInfo databaseInfo, boolean executeQueryType) {
this.databaseInfo = databaseInfo;
this.spanEvent.setExecuteQueryType(executeQueryType);
recordServiceType(executeQueryType ? databaseInfo.getExecuteQueryType() : databaseInfo.getType());
recordEndPoint(databaseInfo.getMultipleHost());
recordDestinationId(databaseInfo.getDatabaseId());
Expand Down

0 comments on commit 7ffa921

Please sign in to comment.