Search in sources :

Example 6 with MeasurementNode

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

the class PublishUtils method createOperationPerf.

public static OperationPerf createOperationPerf(String operation, MeasurementNode statusNode) {
    OperationPerf operationPerf = new OperationPerf();
    operationPerf.setOperation(operation);
    MeasurementNode stageNode = statusNode.findChild(MeterInvocationConst.TAG_STAGE);
    stageNode.getChildren().values().forEach(mNode -> {
        PerfInfo perfInfo = createPerfInfo(mNode);
        operationPerf.getStages().put(mNode.getName(), perfInfo);
    });
    MeasurementNode latencyNode = statusNode.findChild(MeterInvocationConst.TAG_LATENCY_DISTRIBUTION);
    if (latencyNode != null && latencyNode.getMeasurements() != null) {
        operationPerf.setLatencyDistribution(latencyNode.getMeasurements().stream().map(m -> (int) m.value()).toArray(Integer[]::new));
    }
    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 7 with MeasurementNode

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

the class ServerEndpointsLogPublisher method print.

@Override
public void print(boolean printDetail) {
    if (!printDetail) {
        return;
    }
    appendLine(sb, "    server.endpoints:");
    appendLine(sb, "      connectCount disconnectCount rejectByLimit connections requests latency send(Bps) receive(Bps) listen");
    for (MeasurementNode address : measurementNode.getChildren().values()) {
        if (printDetail) {
            appendLine(sb, "      %-12.0f %-15.0f %-13.0f %-11.0f %-8.0f %-7.0f %-9s %-12s %s", address.findChild(EndpointMeter.CONNECT_COUNT).summary(), address.findChild(EndpointMeter.DISCONNECT_COUNT).summary(), address.findChild(ServerEndpointMeter.REJECT_BY_CONNECTION_LIMIT).summary(), address.findChild(EndpointMeter.CONNECTIONS).summary(), address.findChild(EndpointMeter.REQUESTS).summary(), address.findChild(EndpointMeter.LATENCY).summary(), NetUtils.humanReadableBytes((long) address.findChild(EndpointMeter.BYTES_WRITTEN).summary()), NetUtils.humanReadableBytes((long) address.findChild(EndpointMeter.BYTES_READ).summary()), address.getName());
        }
    }
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode)

Example 8 with MeasurementNode

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

the class ThreadPoolMonitorPublishModelFactory method readMeasurement.

protected void readMeasurement(String name, Setter setter) {
    MeasurementNode node = tree.findChild(name);
    if (node == null) {
        return;
    }
    for (Measurement measurement : node.getMeasurements()) {
        String threadPoolName = Utils.getTagValue(measurement.id(), ThreadPoolMonitor.ID_TAG_NAME);
        if (threadPoolName == null) {
            continue;
        }
        ThreadPoolPublishModel model = threadPools.computeIfAbsent(threadPoolName, tpn -> new ThreadPoolPublishModel());
        setter.set(model, measurement);
    }
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) Measurement(com.netflix.spectator.api.Measurement) ThreadPoolPublishModel(org.apache.servicecomb.metrics.core.publish.model.ThreadPoolPublishModel)

Example 9 with MeasurementNode

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

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 10 with MeasurementNode

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

the class Utils method createStatusNode.

public static MeasurementNode createStatusNode(String status, MeasurementNode... stageNodes) {
    MeasurementNode statusNode = new MeasurementNode(status, new HashMap<>());
    MeasurementNode typeNode = new MeasurementNode(MeterInvocationConst.TAG_STAGE, new HashMap<>());
    MeasurementNode latencyNode = new MeasurementNode(MeterInvocationConst.TAG_LATENCY_DISTRIBUTION, new HashMap<>());
    List<Measurement> measurements = latencyNode.getMeasurements();
    measurements.add(new Measurement(null, 0L, 1));
    measurements.add(new Measurement(null, 0L, 2));
    for (MeasurementNode stageNode : stageNodes) {
        typeNode.getChildren().put(stageNode.getName(), stageNode);
    }
    statusNode.getChildren().put(latencyNode.getName(), latencyNode);
    statusNode.getChildren().put(typeNode.getName(), typeNode);
    return statusNode;
}
Also used : MeasurementNode(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementNode) Measurement(com.netflix.spectator.api.Measurement)

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