use of org.springframework.core.metrics.StartupStep in project spring-boot by spring-projects.
the class BufferingApplicationStartupTests method taggingShouldFailWhenRemovingEntry.
@Test
void taggingShouldFailWhenRemovingEntry() {
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(2);
StartupStep step = applicationStartup.start("first");
step.tag("name", "value");
assertThatThrownBy(() -> step.getTags().iterator().remove()).isInstanceOf(UnsupportedOperationException.class);
}
use of org.springframework.core.metrics.StartupStep in project spring-boot by spring-projects.
the class BufferingApplicationStartupTests method shouldNotRecordEventsWhenFiltered.
@Test
void shouldNotRecordEventsWhenFiltered() {
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(5);
applicationStartup.addFilter((step) -> step.getName().startsWith("spring"));
applicationStartup.start("spring.first").end();
StartupStep filtered = applicationStartup.start("filtered.second");
applicationStartup.start("spring.third").end();
filtered.end();
List<TimelineEvent> events = applicationStartup.getBufferedTimeline().getEvents();
assertThat(events).hasSize(2);
StartupTimeline.TimelineEvent firstEvent = events.get(0);
assertThat(firstEvent.getStartupStep().getId()).isEqualTo(0);
assertThat(firstEvent.getStartupStep().getParentId()).isNull();
StartupTimeline.TimelineEvent secondEvent = events.get(1);
assertThat(secondEvent.getStartupStep().getId()).isEqualTo(2);
assertThat(secondEvent.getStartupStep().getParentId()).isEqualTo(1);
}
use of org.springframework.core.metrics.StartupStep in project spring-boot by spring-projects.
the class ServletWebServerApplicationContext method createWebServer.
private void createWebServer() {
WebServer webServer = this.webServer;
ServletContext servletContext = getServletContext();
if (webServer == null && servletContext == null) {
StartupStep createWebServer = this.getApplicationStartup().start("spring.boot.webserver.create");
ServletWebServerFactory factory = getWebServerFactory();
createWebServer.tag("factory", factory.getClass().toString());
this.webServer = factory.getWebServer(getSelfInitializer());
createWebServer.end();
getBeanFactory().registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(this.webServer));
getBeanFactory().registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this, this.webServer));
} else if (servletContext != null) {
try {
getSelfInitializer().onStartup(servletContext);
} catch (ServletException ex) {
throw new ApplicationContextException("Cannot initialize servlet context", ex);
}
}
initPropertySources();
}
use of org.springframework.core.metrics.StartupStep in project spring-boot by spring-projects.
the class SpringApplicationRunListeners method doWithListeners.
private void doWithListeners(String stepName, Consumer<SpringApplicationRunListener> listenerAction, Consumer<StartupStep> stepAction) {
StartupStep step = this.applicationStartup.start(stepName);
this.listeners.forEach(listenerAction);
if (stepAction != null) {
stepAction.accept(step);
}
step.end();
}
use of org.springframework.core.metrics.StartupStep in project spring-boot by spring-projects.
the class ReactiveWebServerApplicationContext method createWebServer.
private void createWebServer() {
WebServerManager serverManager = this.serverManager;
if (serverManager == null) {
StartupStep createWebServer = this.getApplicationStartup().start("spring.boot.webserver.create");
String webServerFactoryBeanName = getWebServerFactoryBeanName();
ReactiveWebServerFactory webServerFactory = getWebServerFactory(webServerFactoryBeanName);
createWebServer.tag("factory", webServerFactory.getClass().toString());
boolean lazyInit = getBeanFactory().getBeanDefinition(webServerFactoryBeanName).isLazyInit();
this.serverManager = new WebServerManager(this, webServerFactory, this::getHttpHandler, lazyInit);
getBeanFactory().registerSingleton("webServerGracefulShutdown", new WebServerGracefulShutdownLifecycle(this.serverManager.getWebServer()));
getBeanFactory().registerSingleton("webServerStartStop", new WebServerStartStopLifecycle(this.serverManager));
createWebServer.end();
}
initPropertySources();
}
Aggregations