Class BufferingApplicationStartup
java.lang.Object
org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup
- All Implemented Interfaces:
org.springframework.core.metrics.ApplicationStartup
public class BufferingApplicationStartup
extends 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:
- Since:
- 2.4.0
-
Field Summary
Fields inherited from interface org.springframework.core.metrics.ApplicationStartup
DEFAULT
-
Constructor Summary
ConstructorDescriptionBufferingApplicationStartup
(int capacity) Create a new bufferedApplicationStartup
with a limited capacity and starts the recording of steps. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a predicate filter to the list of existing ones.Return thetimeline
by pulling steps from the buffer.Return thetimeline
as a snapshot of currently buffered steps.org.springframework.core.metrics.StartupStep
void
Start the recording of steps and mark the beginning of theStartupTimeline
.
-
Constructor Details
-
BufferingApplicationStartup
public BufferingApplicationStartup(int capacity) Create a new bufferedApplicationStartup
with a limited capacity and starts the recording of steps.- Parameters:
capacity
- the configured capacity; once reached, new steps are not recorded.
-
-
Method Details
-
startRecording
public void startRecording()Start the recording of steps and mark the beginning of theStartupTimeline
. The class constructor already implicitly calls this, but it is possible to reset it as long as steps have not been recorded already.- Throws:
IllegalStateException
- if called andStartupStep
have been recorded already.
-
addFilter
Add a predicate filter to the list of existing ones.A
step
that doesn't match all filters will not be recorded.- Parameters:
filter
- the predicate filter to add.
-
start
- Specified by:
start
in interfaceorg.springframework.core.metrics.ApplicationStartup
-
getBufferedTimeline
Return thetimeline
as a snapshot of currently buffered steps.This will not remove steps from the buffer, see
drainBufferedTimeline()
for its counterpart.- Returns:
- a snapshot of currently buffered steps.
-
drainBufferedTimeline
Return thetimeline
by pulling steps from the buffer.This removes steps from the buffer, see
getBufferedTimeline()
for its read-only counterpart.- Returns:
- buffered steps drained from the buffer.
-