Search in sources :

Example 6 with Histogram

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();
}
Also used : Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) AgentHistogram(com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram) Application(com.navercorp.pinpoint.web.vo.Application)

Example 7 with Histogram

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);
    }
}
Also used : Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)

Example 8 with Histogram

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);
}
Also used : TimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram) Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram)

Example 9 with Histogram

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);
}
Also used : TimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram) Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram)

Example 10 with Histogram

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);
}
Also used : HistogramSchema(com.navercorp.pinpoint.common.trace.HistogramSchema) Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

Histogram (com.navercorp.pinpoint.web.applicationmap.histogram.Histogram)11 Test (org.junit.Test)4 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)3 TimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram)3 AgentHistogram (com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogram)3 HashMap (java.util.HashMap)3 HistogramSchema (com.navercorp.pinpoint.common.trace.HistogramSchema)2 AgentTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram)2 ApplicationTimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram)2 Application (com.navercorp.pinpoint.web.vo.Application)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 HistogramSlot (com.navercorp.pinpoint.common.trace.HistogramSlot)1 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 AgentTimeHistogramBuilder (com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogramBuilder)1 ApplicationTimeHistogramBuilder (com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogramBuilder)1 AgentHistogramList (com.navercorp.pinpoint.web.applicationmap.rawdata.AgentHistogramList)1 LinkCallDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallDataMap)1 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)1 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)1