Search in sources :

Example 11 with ModuleStat

use of com.alipay.sofa.boot.startup.ModuleStat 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);
    }
}
Also used : StartupReporter(com.alipay.sofa.startup.StartupReporter) ModuleStat(com.alipay.sofa.boot.startup.ModuleStat) ContextRefreshStageStat(com.alipay.sofa.boot.startup.ContextRefreshStageStat) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException)

Aggregations

ModuleStat (com.alipay.sofa.boot.startup.ModuleStat)11 StartupReporter (com.alipay.sofa.startup.StartupReporter)9 ChildrenStat (com.alipay.sofa.boot.startup.ChildrenStat)8 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)5 BaseStat (com.alipay.sofa.boot.startup.BaseStat)4 BeanStat (com.alipay.sofa.boot.startup.BeanStat)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 BeanLoadCostBeanFactory (com.alipay.sofa.isle.spring.factory.BeanLoadCostBeanFactory)2 ExtensionFactoryBean (com.alipay.sofa.runtime.ext.spring.ExtensionFactoryBean)2 ExtensionPointFactoryBean (com.alipay.sofa.runtime.ext.spring.ExtensionPointFactoryBean)2 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)2 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)2 ContextRefreshStageStat (com.alipay.sofa.boot.startup.ContextRefreshStageStat)1