Search in sources :

Example 1 with EventBusStatistics

use of won.bot.framework.eventbot.bus.impl.EventBusStatistics in project webofneeds by researchstudio-sat.

the class StatisticsLoggingAction method doRun.

@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
    EventBus bus = getEventListenerContext().getEventBus();
    EventBusStatistics statistics = bus.generateEventBusStatistics();
    StringBuilder sb = new StringBuilder();
    sb.append("\nEvent bus statistics: \n").append("number of listeners: ").append(statistics.getListenerCount()).append("\n").append("number of listeners per listener class:\n");
    statistics.getListenerCountPerListenerClass().entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName())).forEach(e -> sb.append(e.getKey().getName()).append(": ").append(e.getValue()).append("\n"));
    sb.append("number of listeners per event class:\n");
    statistics.getListenerCountPerEvent().entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName())).forEach(e -> sb.append(e.getKey()).append(": ").append(e.getValue()).append("\n"));
    logger.info(sb.toString());
}
Also used : Logger(org.slf4j.Logger) Event(won.bot.framework.eventbot.event.Event) EventBusStatistics(won.bot.framework.eventbot.bus.impl.EventBusStatistics) LoggerFactory(org.slf4j.LoggerFactory) EventBus(won.bot.framework.eventbot.bus.EventBus) EventListener(won.bot.framework.eventbot.listener.EventListener) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) EventListenerContext(won.bot.framework.eventbot.EventListenerContext) EventBus(won.bot.framework.eventbot.bus.EventBus) EventBusStatistics(won.bot.framework.eventbot.bus.impl.EventBusStatistics)

Aggregations

Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 EventListenerContext (won.bot.framework.eventbot.EventListenerContext)1 BaseEventBotAction (won.bot.framework.eventbot.action.BaseEventBotAction)1 EventBus (won.bot.framework.eventbot.bus.EventBus)1 EventBusStatistics (won.bot.framework.eventbot.bus.impl.EventBusStatistics)1 Event (won.bot.framework.eventbot.event.Event)1 EventListener (won.bot.framework.eventbot.listener.EventListener)1