public class MiniProfilerExecInitializer
extends java.lang.Object
implements ratpack.exec.ExecInitializer
It starts a profiling session and binds that to the execution.
If the defaultProfilerStoreOption
constructor argument is
ProfilerStoreOption.STORE_RESULTS
, the profiler will be saved to storage
at the end of the execution. if that value is set to ProfilerStoreOption.DISCARD_RESULTS
,
the profiler results will not be saved. The default can be overridden by
binding one of those values to the execution during execution, or by
adding one of StoreMiniProfilerHandler
or DiscardMiniProfilerHandler
to the handler chain.
Constructor and Description |
---|
MiniProfilerExecInitializer(ProfilerProvider provider)
Construct the initializer with the given provider and a default to store all profiler results.
|
MiniProfilerExecInitializer(ProfilerProvider provider,
ProfilerStoreOption defaultProfilerStoreOption)
Construct the initializer with the given provider and default storage option.
|
Modifier and Type | Method and Description |
---|---|
protected void |
executionComplete(ratpack.exec.Execution execution) |
protected java.lang.String |
getProfilerName(ratpack.exec.Execution execution)
Override to customize the name given to the profiling instance.
|
void |
init(ratpack.exec.Execution execution)
Initialize the given execution and bind a new Profiler object
|
protected boolean |
shouldCreateProfilerOnExecutionStart(ratpack.exec.Execution execution)
Controls whether this initializer will start a profiler at the start of the execution for the given execution.
|
public MiniProfilerExecInitializer(ProfilerProvider provider, ProfilerStoreOption defaultProfilerStoreOption)
provider
- the profiler provider to usedefaultProfilerStoreOption
- the default profiler storage behaviourpublic MiniProfilerExecInitializer(ProfilerProvider provider)
provider
- the profiler provider to usepublic void init(ratpack.exec.Execution execution)
The ProfilerProvider
that this initializer was created with will always get bound to the execution.
init
in interface ratpack.exec.ExecInitializer
execution
- the execution whose segment is being interceptedprotected void executionComplete(ratpack.exec.Execution execution)
protected java.lang.String getProfilerName(ratpack.exec.Execution execution)
Default implementation looks for a Ratpack Request
and uses the URI on that if
one is found, otherwise the string "Unknown"
.
execution
- the execution whose segment is being interceptedprotected boolean shouldCreateProfilerOnExecutionStart(ratpack.exec.Execution execution)
Default is to return false, ie profilers are started by some other execution logic, rather than for all executions.
execution
- the execution whose segment is being initializedfalse
for the default implementation