Search in sources :

Example 1 with AgentEventFilter

use of com.navercorp.pinpoint.web.filter.agent.AgentEventFilter in project pinpoint by naver.

the class AgentEventTimelineTest method multipleFilters.

@Test
public void multipleFilters() {
    // Given
    Range timelineRange = new Range(100, 200);
    List<AgentEvent> agentEvents = Arrays.asList(createAgentEvent(110, AgentEventType.AGENT_PING), createAgentEvent(120, AgentEventType.AGENT_CONNECTED), createAgentEvent(130, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(140, AgentEventType.AGENT_UNEXPECTED_SHUTDOWN), createAgentEvent(150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(160, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(170, AgentEventType.USER_THREAD_DUMP), createAgentEvent(180, AgentEventType.OTHER));
    Set<AgentEventType> includedAgentEventTypes = new HashSet<AgentEventType>() {

        {
            add(AgentEventType.AGENT_PING);
            add(AgentEventType.AGENT_CONNECTED);
            add(AgentEventType.AGENT_SHUTDOWN);
            add(AgentEventType.AGENT_CLOSED_BY_SERVER);
        }
    };
    AgentEventFilter excludeUnexpectedEventsFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER);
    AgentEventFilter excludeUserThreadDumpFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.USER_THREAD_DUMP);
    AgentEventFilter excludeOtherFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.OTHER);
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(timelineRange, 1).from(agentEvents).addFilter(excludeUnexpectedEventsFilter).addFilter(excludeUserThreadDumpFilter).addFilter(excludeOtherFilter).build();
    // Then
    int allEventsTotalCount = 0;
    for (AgentEventTimelineSegment segment : timeline.getTimelineSegments()) {
        AgentEventMarker marker = segment.getValue();
        allEventsTotalCount += marker.getTotalCount();
        Map<AgentEventType, Integer> eventTypeCountMap = marker.getTypeCounts();
        Assert.assertTrue(includedAgentEventTypes.containsAll(eventTypeCountMap.keySet()));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.USER_THREAD_DUMP));
        Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.OTHER));
    }
    Assert.assertEquals(allEventsTotalCount, includedAgentEventTypes.size());
}
Also used : Range(com.navercorp.pinpoint.web.vo.Range) AgentEventFilter(com.navercorp.pinpoint.web.filter.agent.AgentEventFilter) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)1 AgentEventFilter (com.navercorp.pinpoint.web.filter.agent.AgentEventFilter)1 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)1 Range (com.navercorp.pinpoint.web.vo.Range)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1