use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.
the class AgentEventTimelineTest method rightBiasedSpread.
@Test
public void rightBiasedSpread() {
// Given
Range range = new Range(0, 199);
AgentEvent event1 = createAgentEvent(0, AgentEventType.AGENT_CONNECTED);
AgentEvent event2 = createAgentEvent(5, AgentEventType.AGENT_PING);
AgentEvent event3 = createAgentEvent(100, AgentEventType.AGENT_PING);
AgentEvent event4 = createAgentEvent(110, AgentEventType.AGENT_PING);
AgentEvent event5 = createAgentEvent(199, AgentEventType.AGENT_PING);
AgentEvent event6 = createAgentEvent(200, AgentEventType.AGENT_SHUTDOWN);
List<AgentEventTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(0, 1, Collections.singletonList(event1)), createSegment(5, 6, Collections.singletonList(event2)), createSegment(99, 199, Arrays.asList(event3, event4, event5, event6)));
// When
AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, 100).from(Arrays.asList(event1, event2, event3, event4, event5, event6)).build();
// Then
Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
}
use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.
the class AgentEventTimelineTest method fullTimeslots_multipleEvents.
@Test
public void fullTimeslots_multipleEvents() {
// Given
long timeRangeMs = TimeUnit.DAYS.toMillis(7);
long from = System.currentTimeMillis();
long to = from + timeRangeMs;
Range range = new Range(from, to);
int numTimeslots = 100;
int expectedEventCountPerSegment = 20;
List<AgentEvent> agentEvents = new ArrayList<>();
for (int i = 0; i < timeRangeMs; i += (timeRangeMs / (numTimeslots * expectedEventCountPerSegment))) {
agentEvents.add(createAgentEvent(from + i, AgentEventType.AGENT_PING));
}
// When
AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, numTimeslots).from(agentEvents).build();
// Then
List<AgentEventTimelineSegment> timelineSegments = timeline.getTimelineSegments();
Assert.assertEquals(numTimeslots, timelineSegments.size());
for (AgentEventTimelineSegment timelineSegment : timelineSegments) {
AgentEventMarker eventMarker = timelineSegment.getValue();
Assert.assertEquals(expectedEventCountPerSegment, eventMarker.getTotalCount());
int pingEventCount = eventMarker.getTypeCounts().get(AgentEventType.AGENT_PING);
Assert.assertEquals(expectedEventCountPerSegment, pingEventCount);
}
}
use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.
the class AgentEventTimelineTest method leftBiasedSpread.
@Test
public void leftBiasedSpread() {
// Given
Range range = new Range(100, 200);
AgentEvent event1 = createAgentEvent(0, AgentEventType.AGENT_CONNECTED);
AgentEvent event2 = createAgentEvent(5, AgentEventType.AGENT_PING);
AgentEvent event3 = createAgentEvent(50, AgentEventType.AGENT_PING);
AgentEvent event4 = createAgentEvent(100, AgentEventType.AGENT_PING);
AgentEvent event5 = createAgentEvent(150, AgentEventType.AGENT_PING);
AgentEvent event6 = createAgentEvent(220, AgentEventType.AGENT_SHUTDOWN);
List<AgentEventTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 101, Arrays.asList(event1, event2, event3, event4)), createSegment(150, 151, Collections.singletonList(event5)), createSegment(199, 200, Collections.singletonList(event6)));
// When
AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, 100).from(Arrays.asList(event1, event2, event3, event4, event5, event6)).build();
// Then
Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
}
use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.
the class AgentInfoServiceImpl method getAgentStatusTimeline.
@Override
public InspectorTimeline getAgentStatusTimeline(String agentId, Range range, int... excludeAgentEventTypeCodes) {
Assert.notNull(agentId, "agentId must not be null");
Assert.notNull(range, "range must not be null");
AgentStatus initialStatus = getAgentStatus(agentId, range.getFrom());
List<AgentEvent> agentEvents = agentEventService.getAgentEvents(agentId, range);
AgentStatusTimelineBuilder agentStatusTimelinebuilder = new AgentStatusTimelineBuilder(range, initialStatus);
agentStatusTimelinebuilder.from(agentEvents);
AgentStatusTimeline agentStatusTimeline = agentStatusTimelinebuilder.build();
AgentEventTimelineBuilder agentEventTimelineBuilder = new AgentEventTimelineBuilder(range);
agentEventTimelineBuilder.from(agentEvents);
agentEventTimelineBuilder.addFilter(new AgentEventFilter.ExcludeFilter(excludeAgentEventTypeCodes));
AgentEventTimeline agentEventTimeline = agentEventTimelineBuilder.build();
return new InspectorTimeline(agentStatusTimeline, agentEventTimeline);
}
use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.
the class AgentEventTimelineBuilder method createTimeslotIndexMap.
private Map<Long, List<AgentEvent>> createTimeslotIndexMap(List<AgentEvent> agentEvents) {
Map<Long, List<AgentEvent>> timeslotIndexMap = new TreeMap<>();
for (AgentEvent agentEvent : agentEvents) {
long timeslotIndex = getTimeslotIndex(agentEvent.getEventTimestamp());
List<AgentEvent> timeslotAgentEvents = timeslotIndexMap.get(timeslotIndex);
if (timeslotAgentEvents == null) {
timeslotAgentEvents = new ArrayList<>();
timeslotIndexMap.put(timeslotIndex, timeslotAgentEvents);
}
timeslotAgentEvents.add(agentEvent);
}
return timeslotIndexMap;
}
Aggregations