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());
}
Aggregations