Search in sources :

Example 1 with MeasurementNode

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

the class PublishUtils method createPerfInfo.

public static PerfInfo createPerfInfo(MeasurementNode stageNode) {
    PerfInfo perfInfo = new PerfInfo();
    perfInfo.setTps((int) 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 2 with MeasurementNode

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

the class PublishUtils method createOperationPerf.

public static OperationPerf createOperationPerf(String operation, MeasurementNode statusNode) {
    OperationPerf operationPerf = new OperationPerf();
    operationPerf.setOperation(operation);
    for (MeasurementNode stageNode : statusNode.getChildren().values()) {
        PerfInfo perfInfo = createPerfInfo(stageNode);
        operationPerf.getStages().put(stageNode.getName(), perfInfo);
    }
    return operationPerf;
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) OperationPerf(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo)

Example 3 with MeasurementNode

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

the class Utils method createStageNode.

public static MeasurementNode createStageNode(String stage, double count, double totalTime, double max) {
    Id id = registry.createId("id").withTag(Statistic.count);
    Measurement countMeasurement = new Measurement(id.withTag(Statistic.count), 0, count);
    Measurement totalTimeMeasurement = new Measurement(id.withTag(Statistic.totalTime), 0, totalTime);
    Measurement maxMeasurement = new Measurement(id.withTag(Statistic.max), 0, max);
    MeasurementNode stageNode = new MeasurementNode(stage, null);
    stageNode.addChild(Statistic.count.name(), countMeasurement);
    stageNode.addChild(Statistic.totalTime.name(), totalTimeMeasurement);
    stageNode.addChild(Statistic.max.name(), maxMeasurement);
    return stageNode;
}
Also used : Measurement(com.netflix.spectator.api.Measurement) MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) Id(com.netflix.spectator.api.Id)

Example 4 with MeasurementNode

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

the class DefaultLogPublisher method printCpuLog.

private void printCpuLog(StringBuilder sb, MeasurementNode osNode) {
    MeasurementNode cpuNode = osNode.findChild(OsMeter.OS_TYPE_ALL_CPU);
    MeasurementNode processNode = osNode.findChild(OsMeter.OS_TYPE_PROCESS_CPU);
    if (cpuNode == null || cpuNode.getMeasurements().isEmpty() || processNode == null || processNode.getMeasurements().isEmpty()) {
        return;
    }
    double allRate = cpuNode.summary();
    double processRate = processNode.summary();
    appendLine(sb, "  cpu:");
    appendLine(sb, "    all usage: %.2f%%    all idle: %.2f%%    process: %.2f%%", allRate * 100, (1 - allRate) * 100, processRate * 100);
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode)

Example 5 with MeasurementNode

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

the class DefaultLogPublisher method printOsLog.

protected void printOsLog(MeasurementTree tree, StringBuilder sb) {
    MeasurementNode osNode = tree.findChild(OsMeter.OS_NAME);
    if (osNode == null || osNode.getMeasurements().isEmpty()) {
        return;
    }
    appendLine(sb, "os:");
    printCpuLog(sb, osNode);
    printNetLog(sb, osNode);
}
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