public class RequestLog extends Object
Modifier and Type | Method and Description |
---|---|
static void |
accumulate(RequestLog ctx)
Accumulates timings and threads to current thread's request log context.
|
static void |
addIdPrefix(String idPrefix)
Prepend an id prefix to generated druid query id.
|
static RequestLog |
copy()
Exports a snapshot of the request log of the current thread without resetting the request log for that thread.
|
static RequestLog |
dump()
Exports a snapshot of the request log of the current thread and also resets the request log for that thread.
|
static String |
export()
Exports current thread's request log object as a formatted string without resetting it.
|
static Map<String,Float> |
getAggregateDurations()
Get the aggregate durations for this request.
|
static Map<String,Long> |
getDurations()
Get the aggregate durations for this request.
|
static String |
getId()
Returns the id of this request log as a string.
|
static boolean |
isRunning(Object caller)
Check if a stopwatch is currently running.
|
static boolean |
isRunning(String timePhaseName)
Check if a stopwatch is currently running.
|
static void |
log()
Write the request log object of the current thread as JSON.
|
static void |
record(LogInfo logPhase)
Record logging information in the logging context.
|
static void |
registerTime(TimedPhase stoppedPhase)
Registers the final duration of a stopped timer with the RequestLog.
|
static void |
restore(RequestLog ctx)
Overwrite current thread's request log context.
|
static LogInfo |
retrieve(Class cls)
Retrieve logging information in the logging context.
|
static Map<String,LogInfo> |
retrieveAll()
Returns a map of all the LogInfo blocks currently registered with this thread's RequestLog.
|
static TimedPhase |
startTiming(Object caller)
Start a stopwatch.
|
static TimedPhase |
startTiming(String timePhaseName)
Start a stopwatch.
|
static void |
stopMostRecentTimer()
Deprecated.
Stopping a timer based on context is brittle, and prone to unexpected changes. Timers should be
stopped explicitly, or started in a try-with-resources block
|
static void |
stopTiming(Object caller)
Pause a stopwatch.
|
static void |
stopTiming(String timePhaseName)
Pause a stopwatch.
|
static void |
switchTiming(String nextPhase)
Deprecated.
This method is too dependent on context that can be too easily changed by internal method calls.
Each timer should be explicitly started by
startTiming(String) and stopped by
stopTiming(String) instead |
public static Map<String,Long> getDurations()
public static Map<String,Float> getAggregateDurations()
public static boolean isRunning(Object caller)
caller
- the caller to name this stopwatch with its class's simple namepublic static boolean isRunning(String timePhaseName)
timePhaseName
- the name of this stopwatchpublic static TimedPhase startTiming(Object caller)
caller
- the caller to name this stopwatch with its class's simple namepublic static TimedPhase startTiming(String timePhaseName)
timePhaseName
- the name of this stopwatch@Deprecated public static void switchTiming(String nextPhase)
startTiming(String)
and stopped by
stopTiming(String)
insteadnextPhase
- the name of the stopwatch to be startedpublic static void stopTiming(Object caller)
caller
- the caller to name this stopwatch with its class's simple namepublic static void registerTime(TimedPhase stoppedPhase)
stoppedPhase
- The phase that has been stopped, and whose duration needs to be storedpublic static void stopTiming(String timePhaseName)
timePhaseName
- the name of this stopwatch@Deprecated public static void stopMostRecentTimer()
public static void record(LogInfo logPhase)
logPhase
- The name of the class destined to hold this logging informationLogBlock
public static LogInfo retrieve(Class cls)
cls
- The class destined to hold this logging informationLogBlock
public static Map<String,LogInfo> retrieveAll()
public static void log()
public static RequestLog dump()
public static RequestLog copy()
public static String getId()
public static void addIdPrefix(String idPrefix)
idPrefix
- Prefix for queryId sent to druidpublic static void restore(RequestLog ctx)
ctx
- the log context to restore to current thread's request logpublic static void accumulate(RequestLog ctx)
ctx
. If the two contexts refer to different requests, then it logs a
warning and returns.ctx
- The log context to accumulate to current thread's request logpublic static String export()
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.