[Profile] Add cpu time cost in query audit (#5051)
This commit is contained in:
@ -75,6 +75,8 @@ public class AuditEvent {
|
||||
public String feIp = "";
|
||||
@AuditField(value = "Stmt")
|
||||
public String stmt = "";
|
||||
@AuditField(value = "CpuTimeMS")
|
||||
public long cpuTimeMs = -1;
|
||||
|
||||
public static class AuditEventBuilder {
|
||||
|
||||
@ -127,6 +129,11 @@ public class AuditEvent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditEventBuilder setCpuTimeMs(long cpuTimeMs) {
|
||||
auditEvent.cpuTimeMs = cpuTimeMs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditEventBuilder setScanRows(long scanRows) {
|
||||
auditEvent.scanRows = scanRows;
|
||||
return this;
|
||||
|
||||
@ -115,6 +115,7 @@ public class ConnectProcessor {
|
||||
.setState(ctx.getState().toString()).setQueryTime(elapseMs)
|
||||
.setScanBytes(statistics == null ? 0 : statistics.scan_bytes)
|
||||
.setScanRows(statistics == null ? 0 : statistics.scan_rows)
|
||||
.setCpuTimeMs(statistics == null ? 0 : statistics.cpu_ms)
|
||||
.setReturnRows(ctx.getReturnRows())
|
||||
.setStmtId(ctx.getStmtId())
|
||||
.setQueryId(ctx.queryId() == null ? "NaN" : DebugUtil.printId(ctx.queryId()));
|
||||
|
||||
@ -1125,6 +1125,9 @@ public class StmtExecutor {
|
||||
if (statisticsForAuditLog.scan_rows == null) {
|
||||
statisticsForAuditLog.scan_rows = 0L;
|
||||
}
|
||||
if (statisticsForAuditLog.cpu_ms == null) {
|
||||
statisticsForAuditLog.cpu_ms = 0L;
|
||||
}
|
||||
return statisticsForAuditLog;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,6 +100,7 @@ public class ConnectProcessorTest {
|
||||
|
||||
statistics.scan_bytes = 0L;
|
||||
statistics.scan_rows = 0L;
|
||||
statistics.cpu_ms = 0L;
|
||||
|
||||
MetricRepo.init();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user