use of com.alipay.sofa.startup.StartupReporter in project sofa-boot by alipay.
the class StartupContextRefreshedListener method onApplicationEvent.
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (applicationContext.equals(event.getApplicationContext())) {
try {
startupReporter = applicationContext.getBean(StartupReporter.class);
} catch (NoSuchBeanDefinitionException e) {
// just happen in unit tests
SofaLogger.warn("Failed to found bean StartupReporter", e);
return;
}
// init ContextRefreshStageStat
ContextRefreshStageStat stageStat = new ContextRefreshStageStat();
stageStat.setStageName(APPLICATION_CONTEXT_REFRESH_STAGE);
stageStat.setStageEndTime(System.currentTimeMillis());
// build root ModuleStat
ModuleStat rootModuleStat = new ModuleStat();
rootModuleStat.setModuleName(ROOT_MODULE_NAME);
rootModuleStat.setModuleEndTime(stageStat.getStageEndTime());
rootModuleStat.setThreadName(Thread.currentThread().getName());
// getBeanStatList from BeanCostBeanPostProcessor
BeanCostBeanPostProcessor beanCostBeanPostProcessor = applicationContext.getBean(BeanCostBeanPostProcessor.class);
rootModuleStat.setBeanStats((beanCostBeanPostProcessor.getBeanStatList()));
// report ContextRefreshStageStat
stageStat.setModuleStats(Collections.singletonList(rootModuleStat));
startupReporter.addCommonStartupStat(stageStat);
}
}
Aggregations