Search in sources :

Example 1 with ContextRefreshStageStat

use of com.alipay.sofa.boot.startup.ContextRefreshStageStat in project sofa-boot by alipay.

the class StartupSpringContextInstallStage method doProcess.

@Override
protected void doProcess() throws Exception {
    contextRefreshStageStat = new ContextRefreshStageStat();
    contextRefreshStageStat.setStageName(ISLE_SPRING_CONTEXT_INSTALL_STAGE);
    contextRefreshStageStat.setStageStartTime(System.currentTimeMillis());
    try {
        super.doProcess();
    } finally {
        contextRefreshStageStat.setStageEndTime(System.currentTimeMillis());
        startupReporter.addCommonStartupStat(contextRefreshStageStat);
    }
}
Also used : ContextRefreshStageStat(com.alipay.sofa.boot.startup.ContextRefreshStageStat)

Example 2 with ContextRefreshStageStat

use of com.alipay.sofa.boot.startup.ContextRefreshStageStat 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

ContextRefreshStageStat (com.alipay.sofa.boot.startup.ContextRefreshStageStat)2 ModuleStat (com.alipay.sofa.boot.startup.ModuleStat)1 StartupReporter (com.alipay.sofa.startup.StartupReporter)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1