Search in sources :

Example 16 with MeasurementNode

use of org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode in project java-chassis by ServiceComb.

the class PublishModelFactory method generateOperationPerfGroups.

protected OperationPerfGroups generateOperationPerfGroups(MeasurementTree tree, String invocationTypeName) {
    MeasurementNode node = tree.findChild(MeterInvocationConst.INVOCATION_NAME, invocationTypeName);
    if (node == null) {
        return null;
    }
    OperationPerfGroups groups = new OperationPerfGroups();
    // group by transport
    for (MeasurementNode transportNode : node.getChildren().values()) {
        // group by operation
        for (MeasurementNode operationNode : transportNode.getChildren().values()) {
            // group by status
            for (MeasurementNode statusNode : operationNode.getChildren().values()) {
                PublishUtils.addOperationPerfGroups(groups, transportNode.getName(), operationNode.getName(), statusNode);
            }
        }
    }
    return groups;
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups)

Example 17 with MeasurementNode

use of org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode in project java-chassis by ServiceComb.

the class PublishUtils method createPerfInfo.

public static PerfInfo createPerfInfo(MeasurementNode stageNode) {
    PerfInfo perfInfo = new PerfInfo();
    perfInfo.setTps(stageNode.findChild(Statistic.count.name()).summary());
    perfInfo.setMsTotalTime(stageNode.findChild(Statistic.totalTime.name()).summary() * 1000);
    // when UT with DefaultRegistry, there is no max value
    MeasurementNode maxNode = stageNode.findChild(Statistic.max.name());
    if (maxNode != null) {
        perfInfo.setMsMaxLatency(maxNode.summary() * 1000);
    }
    return perfInfo;
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo)

Example 18 with MeasurementNode

use of org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode in project java-chassis by ServiceComb.

the class DefaultLogPublisher method printNetLog.

private void printNetLog(StringBuilder sb, MeasurementNode osNode) {
    MeasurementNode netNode = osNode.findChild(OsMeter.OS_TYPE_NET);
    if (netNode == null || netNode.getMeasurements().isEmpty()) {
        return;
    }
    appendLine(sb, "  net:");
    appendLine(sb, "    send(Bps)    recv(Bps)    send(pps)    recv(pps)    interface");
    StringBuilder tmpSb = new StringBuilder();
    for (MeasurementNode interfaceNode : netNode.getChildren().values()) {
        double sendRate = interfaceNode.findChild(NetMeter.TAG_SEND.value()).summary();
        double sendPacketsRate = interfaceNode.findChild(NetMeter.TAG_PACKETS_SEND.value()).summary();
        double receiveRate = interfaceNode.findChild(NetMeter.TAG_RECEIVE.value()).summary();
        double receivePacketsRate = interfaceNode.findChild(NetMeter.TAG_PACKETS_RECEIVE.value()).summary();
        if (sendRate == 0 && receiveRate == 0 && receivePacketsRate == 0 && sendPacketsRate == 0) {
            continue;
        }
        appendLine(tmpSb, "    %-12s %-12s %-12s %-12s %s", NetUtils.humanReadableBytes((long) sendRate), NetUtils.humanReadableBytes((long) receiveRate), NetUtils.humanReadableBytes((long) sendPacketsRate), NetUtils.humanReadableBytes((long) receivePacketsRate), interfaceNode.getName());
    }
    if (tmpSb.length() != 0) {
        sb.append(tmpSb.toString());
    }
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode)

Aggregations

MeasurementNode (org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode)18 PerfInfo (org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo)7 Measurement (com.netflix.spectator.api.Measurement)5 OperationPerf (org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf)3 OperationPerfGroups (org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups)3 Test (org.junit.Test)3 Id (com.netflix.spectator.api.Id)2 ThreadPoolPublishModel (org.apache.servicecomb.metrics.core.publish.model.ThreadPoolPublishModel)2 EventBus (com.google.common.eventbus.EventBus)1 VertxImpl (io.vertx.core.impl.VertxImpl)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Status (javax.ws.rs.core.Response.Status)1 Expectations (mockit.Expectations)1 Injectable (mockit.Injectable)1 Mock (mockit.Mock)1 MockUp (mockit.MockUp)1