Search in sources :

Example 1 with DurationalAgentEvent

use of com.navercorp.pinpoint.web.vo.DurationalAgentEvent in project pinpoint by naver.

the class AgentEventServiceImpl method createAgentEvents.

private List<AgentEvent> createAgentEvents(List<AgentEventBo> agentEventBos, boolean includeEventMessage) {
    if (CollectionUtils.isEmpty(agentEventBos)) {
        return Collections.emptyList();
    }
    List<AgentEvent> agentEvents = new ArrayList<>(agentEventBos.size());
    PriorityQueue<DurationalAgentEvent> durationalAgentEvents = new PriorityQueue<>(agentEventBos.size(), AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR);
    for (AgentEventBo agentEventBo : agentEventBos) {
        if (agentEventBo.getEventType().isCategorizedAs(AgentEventTypeCategory.DURATIONAL)) {
            durationalAgentEvents.add(createDurationalAgentEvent(agentEventBo, includeEventMessage));
        } else {
            agentEvents.add(createAgentEvent(agentEventBo, includeEventMessage));
        }
    }
    long durationStartTimestamp = DurationalAgentEvent.UNKNOWN_TIMESTAMP;
    while (!durationalAgentEvents.isEmpty()) {
        DurationalAgentEvent currentEvent = durationalAgentEvents.remove();
        if (durationStartTimestamp == DurationalAgentEvent.UNKNOWN_TIMESTAMP) {
            durationStartTimestamp = currentEvent.getEventTimestamp();
        }
        currentEvent.setDurationStartTimestamp(durationStartTimestamp);
        DurationalAgentEvent nextEvent = durationalAgentEvents.peek();
        if (nextEvent != null) {
            long nextEventTimestamp = nextEvent.getEventTimestamp();
            currentEvent.setDurationEndTimestamp(nextEventTimestamp);
            durationStartTimestamp = nextEventTimestamp;
        }
        agentEvents.add(currentEvent);
    }
    return agentEvents;
}
Also used : DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) ArrayList(java.util.ArrayList) PriorityQueue(java.util.PriorityQueue) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent)

Aggregations

AgentEventBo (com.navercorp.pinpoint.common.server.bo.AgentEventBo)1 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)1 DurationalAgentEvent (com.navercorp.pinpoint.web.vo.DurationalAgentEvent)1 ArrayList (java.util.ArrayList)1 PriorityQueue (java.util.PriorityQueue)1