File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints
main/java/org/springframework/boot/actuate/startup
test/java/org/springframework/boot/actuate/startup Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ The resulting response is similar to the following:
1616
1717include::{snippets}/startup/http-response.adoc[]
1818
19-
19+ NOTE: The above call resets the application startup steps buffer - subsequent calls to the endpoint will
20+ not include the returned steps. To retrieve a snapshot of the steps recorded so far without removing them
21+ from the startup buffer, make a `GET` request to `/actuator/startup`.
2022
2123[[startup-retrieving-response-structure]]
2224=== Response Structure
Original file line number Diff line number Diff line change 1818
1919import org .springframework .boot .SpringBootVersion ;
2020import org .springframework .boot .actuate .endpoint .annotation .Endpoint ;
21+ import org .springframework .boot .actuate .endpoint .annotation .ReadOperation ;
2122import org .springframework .boot .actuate .endpoint .annotation .WriteOperation ;
2223import org .springframework .boot .context .metrics .buffering .BufferingApplicationStartup ;
2324import org .springframework .boot .context .metrics .buffering .StartupTimeline ;
2829 * application startup}.
2930 *
3031 * @author Brian Clozel
32+ * @author Chris Bono
3133 * @since 2.4.0
3234 */
3335@ Endpoint (id = "startup" )
@@ -50,6 +52,12 @@ public StartupResponse startup() {
5052 return new StartupResponse (startupTimeline );
5153 }
5254
55+ @ ReadOperation
56+ public StartupResponse startupSnapshot () {
57+ StartupTimeline startupTimeline = this .applicationStartup .getBufferedTimeline ();
58+ return new StartupResponse (startupTimeline );
59+ }
60+
5361 /**
5462 * A description of an application startup, primarily intended for serialization to
5563 * JSON.
Original file line number Diff line number Diff line change 3030 * Tests for {@link StartupEndpoint}.
3131 *
3232 * @author Brian Clozel
33+ * @author Chris Bono
3334 */
3435class StartupEndpointTests {
3536
@@ -60,6 +61,19 @@ void bufferIsDrained() {
6061 });
6162 }
6263
64+ @ Test
65+ void bufferIsNotDrained () {
66+ BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup (256 );
67+ ApplicationContextRunner contextRunner = new ApplicationContextRunner ()
68+ .withInitializer ((context ) -> context .setApplicationStartup (applicationStartup ))
69+ .withUserConfiguration (EndpointConfiguration .class );
70+ contextRunner .run ((context ) -> {
71+ StartupEndpoint .StartupResponse startup = context .getBean (StartupEndpoint .class ).startupSnapshot ();
72+ assertThat (startup .getTimeline ().getEvents ()).isNotEmpty ();
73+ assertThat (applicationStartup .getBufferedTimeline ().getEvents ()).isNotEmpty ();
74+ });
75+ }
76+
6377 @ Configuration (proxyBeanMethods = false )
6478 static class EndpointConfiguration {
6579
You can’t perform that action at this time.
0 commit comments