use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class LinkSerializer method serialize.
@Override
public void serialize(Link link, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
// for servermap
jgen.writeStringField("key", link.getLinkName());
// necessary for go.js
jgen.writeStringField("from", link.getFrom().getNodeName());
// necessary for go.js
jgen.writeStringField("to", link.getTo().getNodeName());
// for FilterWizard. from, to agent mapping data
writeAgentId("fromAgent", link.getFrom(), jgen);
writeAgentId("toAgent", link.getTo(), jgen);
writeSimpleNode("sourceInfo", link.getFrom(), jgen);
writeSimpleNode("targetInfo", link.getTo(), jgen);
Application filterApplication = link.getFilterApplication();
jgen.writeStringField("filterApplicationName", filterApplication.getName());
jgen.writeNumberField("filterApplicationServiceTypeCode", filterApplication.getServiceTypeCode());
jgen.writeStringField("filterApplicationServiceTypeName", filterApplication.getServiceType().getName());
if (link.isWasToWasLink()) {
writeWasToWasTargetRpcList(link, jgen);
}
Histogram histogram = link.getHistogram();
// for go.js
jgen.writeNumberField("totalCount", histogram.getTotalCount());
jgen.writeNumberField("errorCount", histogram.getTotalErrorCount());
jgen.writeNumberField("slowCount", histogram.getSlowCount());
jgen.writeObjectField("histogram", histogram);
// data showing how agents call each of their respective links
writeAgentHistogram("sourceHistogram", link.getSourceList(), jgen);
writeAgentHistogram("targetHistogram", link.getTargetList(), jgen);
writeTimeSeriesHistogram(link, jgen);
writeSourceAgentTimeSeriesHistogram(link, jgen);
// String state = link.getLinkState();
// jgen.writeStringField("state", state); // for go.js
// for go.js
jgen.writeBooleanField("hasAlert", link.getLinkAlert());
jgen.writeEndObject();
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class NodeSerializer method writeHistogram.
private void writeHistogram(JsonGenerator jgen, Node node) throws IOException {
final ServiceType serviceType = node.getServiceType();
final NodeHistogram nodeHistogram = node.getNodeHistogram();
// FIXME isn't this all ServiceTypes that can be a node?
if (serviceType.isWas() || serviceType.isTerminal() || serviceType.isUnknown() || serviceType.isUser() || serviceType.isQueue()) {
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
if (applicationHistogram == null) {
writeEmptyObject(jgen, "histogram");
// for go.js
jgen.writeBooleanField("hasAlert", false);
} else {
jgen.writeObjectField("histogram", applicationHistogram);
// for go.js
jgen.writeNumberField("totalCount", applicationHistogram.getTotalCount());
jgen.writeNumberField("errorCount", applicationHistogram.getTotalErrorCount());
jgen.writeNumberField("slowCount", applicationHistogram.getSlowCount());
if (applicationHistogram.getTotalCount() == 0) {
// for go.js
jgen.writeBooleanField("hasAlert", false);
} else {
long error = applicationHistogram.getTotalErrorCount() / applicationHistogram.getTotalCount();
if (error * 100 > 10) {
// for go.js
jgen.writeBooleanField("hasAlert", true);
} else {
// for go.js
jgen.writeBooleanField("hasAlert", false);
}
}
}
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
if (agentHistogramMap == null) {
writeEmptyObject(jgen, "agentHistogram");
} else {
jgen.writeObjectField("agentHistogram", agentHistogramMap);
}
} else {
// for go.js
jgen.writeBooleanField("hasAlert", false);
}
// FIXME isn't this all ServiceTypes that can be a node?
if (serviceType.isWas() || serviceType.isUser() || serviceType.isTerminal() || serviceType.isUnknown() || serviceType.isQueue()) {
List<ResponseTimeViewModel> applicationTimeSeriesHistogram = nodeHistogram.getApplicationTimeHistogram();
if (applicationTimeSeriesHistogram == null) {
writeEmptyArray(jgen, "timeSeriesHistogram");
} else {
jgen.writeObjectField("timeSeriesHistogram", applicationTimeSeriesHistogram);
}
AgentResponseTimeViewModelList agentTimeSeriesHistogram = nodeHistogram.getAgentTimeHistogram();
jgen.writeObject(agentTimeSeriesHistogram);
}
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class ResponseTime method addResponseTime.
public void addResponseTime(String agentId, int elapsedTime, boolean error) {
Histogram histogram = getHistogram(agentId);
histogram.addCallCountByElapsedTime(elapsedTime, error);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class ResponseTime method addResponseTime.
public void addResponseTime(String agentId, Histogram copyHistogram) {
if (copyHistogram == null) {
throw new NullPointerException("copyHistogram must not be null");
}
Histogram histogram = getHistogram(agentId);
histogram.add(copyHistogram);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.Histogram in project pinpoint by naver.
the class HistogramTest method testJson.
@Test
public void testJson() throws Exception {
HistogramSchema schema = ServiceType.STAND_ALONE.getHistogramSchema();
Histogram original = new Histogram(ServiceType.STAND_ALONE);
original.addCallCount(schema.getFastSlot().getSlotTime(), 100);
String json = objectMapper.writeValueAsString(original);
HashMap hashMap = objectMapper.readValue(json, HashMap.class);
Assert.assertEquals(hashMap.get(schema.getFastSlot().getSlotName()), 100);
Assert.assertEquals(hashMap.get(schema.getErrorSlot().getSlotName()), 0);
}
Aggregations