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;
}
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());
}
}
}
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);
}
}
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;
}
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;
}
Aggregations