public class BufferingApplicationStartup
extends java.lang.Object
implements org.springframework.core.metrics.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:
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(java.util.function.Predicate<org.springframework.core.metrics.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. |
org.springframework.core.metrics.StartupStep |
start(java.lang.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.java.lang.IllegalStateException
- if called and StartupStep
have been recorded
already.public void addFilter(java.util.function.Predicate<org.springframework.core.metrics.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 org.springframework.core.metrics.StartupStep start(java.lang.String name)
start
in interface org.springframework.core.metrics.ApplicationStartup