public abstract class BaseProfilerProvider extends java.lang.Object implements ProfilerProvider
Constructor and Description |
---|
BaseProfilerProvider() |
Modifier and Type | Method and Description |
---|---|
Profiler |
current()
Returns the current MiniProfiler.
|
Profiler |
getCurrent()
Returns the current MiniProfiler.
|
java.lang.String |
getDefaultHostname()
Return the local host name, or the loopback name (usually "localhost")
if it doesn't resolve in DNS.
|
java.lang.String |
getMachineName()
Returnes the current machine name set
|
Storage |
getStorage()
Return the current storage implementation.
|
ProfilerUiConfig |
getUiConfig()
Returns the
ProfilerUiConfig associated with this provider. |
boolean |
hasCurrent()
Indicates whether there is currently a profiler in the context.
|
protected abstract Profiler |
lookupCurrentProfiler()
Return the current profiler, if any.
|
protected abstract void |
profilerCreated(Profiler profiler)
Called after a new profiler is created.
|
protected abstract void |
profilerStopped(Profiler profiler)
Called after a profiler has been stopped.
|
void |
setMachineName(java.lang.String machineName)
Sets the machine name for the current machine.
|
void |
setStorage(Storage storage)
Set the profiler storage to be used by this provider.
|
void |
setUiConfig(ProfilerUiConfig uiConfig)
Sets the
ProfilerUiConfig for this provider to use. |
void |
setUserProvider(UserProvider userProvider)
Sets the user provider for this profiler provider.
|
Profiler |
start(java.lang.String rootName)
Create a new profiling session with Info profiling level.
|
Profiler |
start(java.lang.String rootName,
ProfileLevel level)
Create a new profiling session.
|
Profiler |
start(java.util.UUID id,
java.lang.String rootName)
Create a new profiling session with Info profiling level.
|
Profiler |
start(java.util.UUID id,
java.lang.String rootName,
ProfileLevel level)
Start a new profiling session with the given level, root name and UUID.
|
void |
stopCurrentSession(boolean discardResults)
Ends the current profiling session, if one exists.
|
void |
stopSession(ProfilerImpl profilingSession,
boolean discardResults)
Marks the given profiling session as stopped.
|
protected abstract void profilerCreated(Profiler profiler)
current()
.profiler
- the newly created profilerprotected abstract void profilerStopped(Profiler profiler)
current()
should return null.profiler
- the stopped profilerprotected abstract Profiler lookupCurrentProfiler()
public final Profiler current()
current
in interface ProfilerProvider
public final Profiler getCurrent()
getCurrent
in interface ProfilerProvider
public boolean hasCurrent()
hasCurrent
in interface ProfilerProvider
public Profiler start(java.lang.String rootName)
start
in interface ProfilerProvider
rootName
- A name for the session. Thiis is used as the name
of the root timing node for the session, and could be
the currently rendering URL or background job name.public Profiler start(java.util.UUID id, java.lang.String rootName)
start
in interface ProfilerProvider
id
- the UUID to userootName
- A name for the session. Thiis is used as the name
of the root timing node for the session, and could be
the currently rendering URL or background job name.public Profiler start(java.lang.String rootName, ProfileLevel level)
start
in interface ProfilerProvider
rootName
- A name for the session. Thiis is used as the name
of the root timing node for the session, and could be
the currently rendering URL or background job name.level
- The level of detail to use when profilingpublic Profiler start(java.util.UUID id, java.lang.String rootName, ProfileLevel level)
start
in interface ProfilerProvider
id
- the UUID to userootName
- the name of the root timing step. This might often be the uri of the current request.level
- the level of the profiling sessionpublic void stopCurrentSession(boolean discardResults)
stopCurrentSession
in interface ProfilerProvider
discardResults
- When true, clears the miniprofiler for this request, allowing profiling to
be prematurely stopped and discarded. Useful for when a specific route does not need to be profiled.public void stopSession(ProfilerImpl profilingSession, boolean discardResults)
stopSession
in interface ProfilerProvider
profilingSession
- the profiler to register as stoppeddiscardResults
- When true, clears the miniprofiler for this request, allowing profiling to
be prematurely stopped and discarded. Useful for when a specific route does not need to be profiled.public void setStorage(Storage storage)
The profiler storage is where profiler sessions are stored to be retrieved later, either by an AJAX call immediately after a page render, or for later debugging.
By default, the storage property is set to an in-memory
MapStorage
.
setStorage
in interface ProfilerProvider
storage
- the storage option to useStorage
public Storage getStorage()
getStorage
in interface ProfilerProvider
public void setMachineName(java.lang.String machineName)
getDefaultHostname()
.machineName
- the machine name to usepublic java.lang.String getMachineName()
public void setUserProvider(UserProvider userProvider)
userProvider
- The user provider to use.UserProvider
public java.lang.String getDefaultHostname()
InetAddress.getHostName()
public ProfilerUiConfig getUiConfig()
ProfilerUiConfig
associated with this provider.getUiConfig
in interface ProfilerProvider
public void setUiConfig(ProfilerUiConfig uiConfig)
ProfilerUiConfig
for this provider to use.setUiConfig
in interface ProfilerProvider
uiConfig
- the UI config to use