use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class HistogramTest method testDeepCopy.
@Test
public void testDeepCopy() throws Exception {
Histogram original = new Histogram(ServiceType.STAND_ALONE);
original.addCallCount((short) 1000, 100);
Histogram copy = new Histogram(ServiceType.STAND_ALONE);
Assert.assertEquals(copy.getFastCount(), 0);
copy.add(original);
Assert.assertEquals(original.getFastCount(), copy.getFastCount());
copy.addCallCount((short) 1000, 100);
Assert.assertEquals(original.getFastCount(), 100);
Assert.assertEquals(copy.getFastCount(), 200);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class ResponseTime method addResponseTime.
public void addResponseTime(String agentId, short slotNumber, long count) {
Histogram histogram = getHistogram(agentId);
histogram.addCallCount(slotNumber, count);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class HistogramSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
Histogram original = new Histogram(ServiceType.STAND_ALONE);
HistogramSchema schema = original.getHistogramSchema();
original.addCallCount(schema.getFastSlot().getSlotTime(), 1);
original.addCallCount(schema.getNormalSlot().getSlotTime(), 2);
original.addCallCount(schema.getSlowSlot().getSlotTime(), 3);
original.addCallCount(schema.getVerySlowSlot().getSlotTime(), 4);
original.addCallCount(schema.getNormalErrorSlot().getSlotTime(), 5);
String jacksonJson = objectMapper.writeValueAsString(original);
HashMap objectMapperHashMap = objectMapper.readValue(jacksonJson, HashMap.class);
logger.debug(jacksonJson);
String internalJson = internalJson(original);
HashMap hashMap = objectMapper.readValue(internalJson, HashMap.class);
Assert.assertEquals(objectMapperHashMap, hashMap);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class ResponseTimeMapperTest method testResponseTimeMapperTest.
@Test
public void testResponseTimeMapperTest() throws Exception {
Buffer buffer = new AutomaticBuffer();
HistogramSlot histogramSlot = ServiceType.STAND_ALONE.getHistogramSchema().findHistogramSlot(1000, false);
short histogramSlotTime = histogramSlot.getSlotTime();
buffer.putShort(histogramSlotTime);
buffer.putBytes(Bytes.toBytes("agent"));
byte[] bufferArray = buffer.getBuffer();
byte[] valueArray = Bytes.toBytes(1L);
Cell mockCell = CellUtil.createCell(HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, bufferArray, HConstants.LATEST_TIMESTAMP, KeyValue.Type.Maximum.getCode(), valueArray);
ResponseTimeMapper responseTimeMapper = new ResponseTimeMapper();
ResponseTime responseTime = new ResponseTime("applicationName", ServiceType.STAND_ALONE, System.currentTimeMillis());
responseTimeMapper.recordColumn(responseTime, mockCell);
Histogram agentHistogram = responseTime.findHistogram("agent");
long fastCount = agentHistogram.getFastCount();
Assert.assertEquals(fastCount, 1);
long normal = agentHistogram.getNormalCount();
Assert.assertEquals(normal, 0);
long slow = agentHistogram.getSlowCount();
Assert.assertEquals(slow, 0);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class ApplicationMapBuilder method filterAgentInfoByResponseData.
/**
* Filters AgentInfo by whether they actually have response data.
* For agents that do not have response data, check their status and include those that were alive.
*/
private Set<AgentInfo> filterAgentInfoByResponseData(Set<AgentInfo> agentList, long timestamp, Node node, AgentInfoService agentInfoService) {
Set<AgentInfo> filteredAgentInfo = new HashSet<>();
NodeHistogram nodeHistogram = node.getNodeHistogram();
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
for (AgentInfo agentInfo : agentList) {
String agentId = agentInfo.getAgentId();
if (agentHistogramMap.containsKey(agentId)) {
filteredAgentInfo.add(agentInfo);
} else {
AgentStatus status = agentInfoService.getAgentStatus(agentId, timestamp);
agentInfo.setStatus(status);
if (isAgentRunning(agentInfo)) {
filteredAgentInfo.add(agentInfo);
}
}
}
return filteredAgentInfo;
}
Aggregations