public class QueryPerformanceRecorder extends Object implements Serializable
QueryPerformanceNugget
instances.
Thread-safety note: This used to be thread-safe only by virtue of using a thread-local instance. Now it's aggressively synchronized so we can abort it from outside the "owner" thread.
Constructor and Description |
---|
QueryPerformanceRecorder() |
Modifier and Type | Method and Description |
---|---|
void |
abortQuery()
This is for use by the RemoteQueryProcessor.
|
static void |
clearCallsite()
Clear any previously set callsite.
|
boolean |
endQuery()
This is for use by the RemoteQueryProcessor.
|
static void |
flushLocalInstance()
Deprecated.
No longer used.
|
static String |
getCallerLine() |
static long |
getFirstTimeDataReadNanos() |
static long |
getFirstTimeDataReads() |
static QueryPerformanceRecorder |
getInstance() |
QueryPerformanceNugget |
getNugget(String name) |
QueryPerformanceNugget |
getNugget(String name,
long inputSize) |
List<QueryPerformanceNugget> |
getOperationLevelPerformanceData() |
com.fishlib.auth.UserContext |
getOperationUserContext() |
QueryPerformanceNugget |
getOuterMostNugget() |
QueryPerformanceNugget |
getOuterNugget() |
com.fishlib.auth.UserContext |
getPrimaryUserContext() |
QueryPerformanceNugget |
getQueryLevelPerformanceData() |
static long |
getRepeatedDataReadNanos() |
static long |
getRepeatedDataReads() |
QueryState |
getState()
Return the query's current state
|
Table |
getTimingResultsAsTable() |
static void |
recordFirstTimeDataRead(long durationNanos) |
static void |
recordRepeatedDataRead(long durationNanos) |
static void |
resetInstance() |
static boolean |
setCallsite()
Attempt to compute and set the thread local callsite so that invocations of
QueryPerformanceRecorder.getCallerLine()
will not spend time trying to recompute. |
static boolean |
setCallsite(String callsite)
Attempt to set the thread local callsite so that invocations of
QueryPerformanceRecorder.getCallerLine() will not spend time trying
to recompute. |
void |
showLineNumbers()
Deprecated.
Recording the caller line is now enabled for all nuggets by default.
|
void |
startQuery(String description)
Deprecated.
|
void |
startQuery(String description,
com.fishlib.auth.UserContext primaryUserContext,
com.fishlib.auth.UserContext operationUserContext)
This is for use by the RemoteQueryProcessor.
|
static void |
withNugget(String name,
long inputSize,
com.fishlib.base.Procedure.Nullary r)
Surround the given code with a Performance Nugget
|
static <T> T |
withNugget(String name,
long inputSize,
Supplier<T> r)
Surround the given code with a Performance Nugget
|
static void |
withNugget(String name,
com.fishlib.base.Procedure.Nullary r)
Surround the given code with a Performance Nugget
|
static <T> T |
withNugget(String name,
Supplier<T> r)
Surround the given code with a Performance Nugget
|
static <R,ExceptionType extends Exception> |
withNuggetThrowing(String name,
com.fishlib.base.Function.ThrowingNullary<R,ExceptionType> r)
Surround the given code with a Performance Nugget
|
static <R,ExceptionType extends Exception> |
withNuggetThrowing(String name,
long inputSize,
com.fishlib.base.Function.ThrowingNullary<R,ExceptionType> r)
Surround the given code with a Performance Nugget
|
static <T extends Exception> |
withNuggetThrowing(String name,
long inputSize,
com.fishlib.base.Procedure.ThrowingNullary<T> r)
Surround the given code with a Performance Nugget
|
static <T extends Exception> |
withNuggetThrowing(String name,
com.fishlib.base.Procedure.ThrowingNullary<T> r)
Surround the given code with a Performance Nugget
|
public static QueryPerformanceRecorder getInstance()
public static void resetInstance()
public void startQuery(String description, com.fishlib.auth.UserContext primaryUserContext, com.fishlib.auth.UserContext operationUserContext)
description
- the query's Action nameprimaryUserContext
- the query's user contextoperationUserContext
- the client's user context@Deprecated public void startQuery(String description)
description
- the query's Action namepublic void abortQuery()
public QueryState getState()
public boolean endQuery()
public QueryPerformanceNugget getNugget(String name)
name
- the nugget namepublic QueryPerformanceNugget getNugget(String name, long inputSize)
name
- the nugget nameinputSize
- the nugget's input sizepublic QueryPerformanceNugget getOuterNugget()
public QueryPerformanceNugget getOuterMostNugget()
public QueryPerformanceNugget getQueryLevelPerformanceData()
public com.fishlib.auth.UserContext getPrimaryUserContext()
public com.fishlib.auth.UserContext getOperationUserContext()
public List<QueryPerformanceNugget> getOperationLevelPerformanceData()
public Table getTimingResultsAsTable()
@Deprecated public static void flushLocalInstance()
@Deprecated public void showLineNumbers()
public static void recordFirstTimeDataRead(long durationNanos)
public static void recordRepeatedDataRead(long durationNanos)
public static long getFirstTimeDataReads()
public static long getFirstTimeDataReadNanos()
public static long getRepeatedDataReads()
public static long getRepeatedDataReadNanos()
public static String getCallerLine()
public static void withNugget(String name, com.fishlib.base.Procedure.Nullary r)
name
- the nugget namer
- the stuff to runpublic static <T> T withNugget(String name, Supplier<T> r)
name
- the nugget namer
- the stuff to runpublic static <T extends Exception> void withNuggetThrowing(String name, com.fishlib.base.Procedure.ThrowingNullary<T> r) throws T extends Exception
r
- the stuff to runT
- exception of type TT extends Exception
public static <R,ExceptionType extends Exception> R withNuggetThrowing(String name, com.fishlib.base.Function.ThrowingNullary<R,ExceptionType> r) throws ExceptionType extends Exception
name
- the nugget namer
- the stuff to runExceptionType
- exception of type ExceptionTypeExceptionType extends Exception
public static void withNugget(String name, long inputSize, com.fishlib.base.Procedure.Nullary r)
name
- the nugget namer
- the stuff to runpublic static <T> T withNugget(String name, long inputSize, Supplier<T> r)
name
- the nugget namer
- the stuff to runpublic static <T extends Exception> void withNuggetThrowing(String name, long inputSize, com.fishlib.base.Procedure.ThrowingNullary<T> r) throws T extends Exception
r
- the stuff to runT
- exception of type TT extends Exception
public static <R,ExceptionType extends Exception> R withNuggetThrowing(String name, long inputSize, com.fishlib.base.Function.ThrowingNullary<R,ExceptionType> r) throws ExceptionType extends Exception
name
- the nugget namer
- the stuff to runExceptionType
- exception of type ExceptionTypeExceptionType extends Exception
public static boolean setCallsite(String callsite)
Attempt to set the thread local callsite so that invocations of QueryPerformanceRecorder.getCallerLine()
will not spend time trying
to recompute.
This method returns a boolean if the value was successfully set. In the event this returns true, it's the
responsibility of the caller to invoke QueryPerformanceRecorder.clearCallsite()
when the operation is complete.
It is good practice to do this with try{} finally{} block
final boolean shouldClear = QueryPerformanceRecorder.setCallsite("CALLSITE"); try { // Do work } finally { if(shouldClear) { QueryPerformanceRecorder.clearCallsite(); } }
callsite
- The call site to use.public static boolean setCallsite()
Attempt to compute and set the thread local callsite so that invocations of QueryPerformanceRecorder.getCallerLine()
will not spend time trying to recompute.
Users should follow the best practice as described by QueryPerformanceRecorder.setCallsite(String)
public static void clearCallsite()
QueryPerformanceRecorder.setCallsite(String)