Skip to content

Commit

Permalink
[#10604] 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 5597513
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;
}

Check warning on line 211 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/SpanEvent.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/SpanEvent.java#L210-L211

Added lines #L210 - L211 were not covered by tests

public boolean isExecuteQueryType() {
return executeQueryType;

Check warning on line 214 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/SpanEvent.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/SpanEvent.java#L214

Added line #L214 was not covered by tests
}

@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);

Check warning on line 123 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/WrappedSpanEventRecorder.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/WrappedSpanEventRecorder.java#L123

Added line #L123 was not covered by tests
recordServiceType(executeQueryType ? databaseInfo.getExecuteQueryType() : databaseInfo.getType());
recordEndPoint(databaseInfo.getMultipleHost());
recordDestinationId(databaseInfo.getDatabaseId());
Expand Down

0 comments on commit 5597513

Please sign in to comment.