public class BufferingApplicationStartup extends Object implements ApplicationStartup
ApplicationStartup
implementation that buffers steps
and
records their timestamp as well as their processing time.
Once recording has been started
, steps are buffered up until
the configured capacity
; after that, new
steps are not recorded.
There are several ways to keep the buffer size low:
DEFAULT
Constructor and Description |
---|
BufferingApplicationStartup(int capacity)
Create a new buffered
ApplicationStartup with a limited capacity and starts
the recording of steps. |
Modifier and Type | Method and Description |
---|---|
void |
addFilter(Predicate<StartupStep> filter)
Add a predicate filter to the list of existing ones.
|
StartupTimeline |
drainBufferedTimeline()
Return the
timeline by pulling steps from the buffer. |
StartupTimeline |
getBufferedTimeline()
Return the
timeline as a snapshot of currently buffered
steps. |
StartupStep |
start(String name) |
void |
startRecording()
Start the recording of steps and mark the beginning of the
StartupTimeline . |
public BufferingApplicationStartup(int capacity)
ApplicationStartup
with a limited capacity and starts
the recording of steps.capacity
- the configured capacity; once reached, new steps are not recorded.public void startRecording()
StartupTimeline
.
The class constructor already implicitly calls this, but it is possible to reset it
as long as steps have not been recorded already.IllegalStateException
- if called and StartupStep
have been recorded
already.public void addFilter(Predicate<StartupStep> filter)
A step
that doesn't match all filters will not be recorded.
filter
- the predicate filter to add.public StartupTimeline getBufferedTimeline()
timeline
as a snapshot of currently buffered
steps.
This will not remove steps from the buffer, see drainBufferedTimeline()
for its counterpart.
public StartupTimeline drainBufferedTimeline()
timeline
by pulling steps from the buffer.
This removes steps from the buffer, see getBufferedTimeline()
for its
read-only counterpart.
public StartupStep start(String name)
start
in interface ApplicationStartup