Add checkTime property to verbose data (#2226)

This commit is contained in:
Luck 2020-04-26 10:49:52 +01:00
parent f484e87828
commit c03aca35d6
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 20 additions and 7 deletions

View File

@ -80,11 +80,12 @@ public class VerboseHandler implements AutoCloseable {
return;
}
long time = System.currentTimeMillis();
Throwable trace = new Throwable();
String thread = Thread.currentThread().getName();
// add the check data to a queue to be processed later.
this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, permission, result));
this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, time, trace, thread, permission, result));
}
/**
@ -105,11 +106,12 @@ public class VerboseHandler implements AutoCloseable {
return;
}
long time = System.currentTimeMillis();
Throwable trace = new Throwable();
String thread = Thread.currentThread().getName();
// add the check data to a queue to be processed later.
this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, key, result));
this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, time, trace, thread, key, result));
}
/**

View File

@ -46,8 +46,8 @@ public class MetaCheckEvent extends VerboseEvent {
*/
private final String result;
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String key, String result) {
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String key, String result) {
super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
this.origin = origin;
this.key = key;
this.result = result;

View File

@ -47,8 +47,8 @@ public class PermissionCheckEvent extends VerboseEvent {
*/
private final TristateResult result;
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
super(checkTarget, checkQueryOptions, checkTime, checkTrace, checkThread);
this.origin = origin;
this.permission = permission;
this.result = result;

View File

@ -53,6 +53,11 @@ public abstract class VerboseEvent implements VariableEvaluator {
*/
private final QueryOptions checkQueryOptions;
/**
* The time when the check took place
*/
private final long checkTime;
/**
* The throwable created when the check took place
*/
@ -63,9 +68,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
*/
private final String checkThread;
protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread) {
protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, long checkTime, Throwable checkTrace, String checkThread) {
this.checkTarget = checkTarget;
this.checkQueryOptions = checkQueryOptions;
this.checkTime = checkTime;
this.checkTrace = checkTrace;
this.checkThread = checkThread;
}
@ -78,6 +84,10 @@ public abstract class VerboseEvent implements VariableEvaluator {
return this.checkQueryOptions;
}
public long getCheckTime() {
return this.checkTime;
}
public StackTraceElement[] getCheckTrace() {
return this.checkTrace.getStackTrace();
}
@ -105,6 +115,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
);
}
})
.add("time", this.checkTime)
.add("trace", new JArray()
.consume(arr -> {
int overflow = tracePrinter.process(getCheckTrace(), StackTracePrinter.elementToString(arr::add));