use of org.springframework.boot.context.metrics.buffering.StartupTimeline.TimelineEvent 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.boot.context.metrics.buffering.StartupTimeline.TimelineEvent in project spring-boot by spring-projects.
the class BufferingApplicationStartup method record.
private void record(BufferedStartupStep step) {
if (this.filter.test(step) && this.estimatedSize.get() < this.capacity) {
this.estimatedSize.incrementAndGet();
this.events.add(new TimelineEvent(step, this.clock.instant()));
}
while (true) {
BufferedStartupStep current = this.current.get();
BufferedStartupStep next = getLatestActive(current);
if (this.current.compareAndSet(current, next)) {
return;
}
}
}
Aggregations