Add support for GET requests for /actuator/startup
See gh-24717
This commit is contained in:
parent
8a6e79dc8b
commit
4b8d6efc12
|
|
@ -16,7 +16,9 @@ The resulting response is similar to the following:
|
|||
|
||||
include::{snippets}/startup/http-response.adoc[]
|
||||
|
||||
|
||||
NOTE: The above call resets the application startup steps buffer - subsequent calls to the endpoint will
|
||||
not include the returned steps. To retrieve a snapshot of the steps recorded so far without removing them
|
||||
from the startup buffer, make a `GET` request to `/actuator/startup`.
|
||||
|
||||
[[startup-retrieving-response-structure]]
|
||||
=== Response Structure
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.actuate.startup;
|
|||
|
||||
import org.springframework.boot.SpringBootVersion;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
import org.springframework.boot.context.metrics.buffering.StartupTimeline;
|
||||
|
|
@ -28,6 +29,7 @@ import org.springframework.boot.context.metrics.buffering.StartupTimeline;
|
|||
* application startup}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Chris Bono
|
||||
* @since 2.4.0
|
||||
*/
|
||||
@Endpoint(id = "startup")
|
||||
|
|
@ -50,6 +52,12 @@ public class StartupEndpoint {
|
|||
return new StartupResponse(startupTimeline);
|
||||
}
|
||||
|
||||
@ReadOperation
|
||||
public StartupResponse startupSnapshot() {
|
||||
StartupTimeline startupTimeline = this.applicationStartup.getBufferedTimeline();
|
||||
return new StartupResponse(startupTimeline);
|
||||
}
|
||||
|
||||
/**
|
||||
* A description of an application startup, primarily intended for serialization to
|
||||
* JSON.
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* Tests for {@link StartupEndpoint}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Chris Bono
|
||||
*/
|
||||
class StartupEndpointTests {
|
||||
|
||||
|
|
@ -60,6 +61,19 @@ class StartupEndpointTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void bufferIsNotDrained() {
|
||||
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(256);
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withInitializer((context) -> context.setApplicationStartup(applicationStartup))
|
||||
.withUserConfiguration(EndpointConfiguration.class);
|
||||
contextRunner.run((context) -> {
|
||||
StartupEndpoint.StartupResponse startup = context.getBean(StartupEndpoint.class).startupSnapshot();
|
||||
assertThat(startup.getTimeline().getEvents()).isNotEmpty();
|
||||
assertThat(applicationStartup.getBufferedTimeline().getEvents()).isNotEmpty();
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class EndpointConfiguration {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue