use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups in project incubator-servicecomb-java-chassis by apache.
the class TestDefaultLogPublisher method onPolledEvent.
@Test
public void onPolledEvent(@Mocked VertxImplEx vertxImplEx) {
new Expectations(VertxUtils.class) {
{
VertxUtils.getVertxMap();
result = Collections.singletonMap("v", vertxImplEx);
vertxImplEx.getEventLoopContextCreatedCount();
result = 1;
}
};
DefaultPublishModel model = new DefaultPublishModel();
PerfInfo perfTotal = new PerfInfo();
perfTotal.setTps(10);
perfTotal.setMsTotalTime(100);
OperationPerf operationPerf = new OperationPerf();
operationPerf.setOperation("op");
operationPerf.getStages().put(MeterInvocationConst.STAGE_TOTAL, perfTotal);
operationPerf.getStages().put(MeterInvocationConst.STAGE_EXECUTOR_QUEUE, perfTotal);
operationPerf.getStages().put(MeterInvocationConst.STAGE_EXECUTION, perfTotal);
OperationPerfGroup operationPerfGroup = new OperationPerfGroup(Const.RESTFUL, Status.OK.name());
operationPerfGroup.addOperationPerf(operationPerf);
OperationPerfGroups operationPerfGroups = new OperationPerfGroups();
operationPerfGroups.getGroups().put(operationPerfGroup.getTransport(), Collections.singletonMap(operationPerfGroup.getStatus(), operationPerfGroup));
model.getConsumer().setOperationPerfGroups(operationPerfGroups);
model.getProducer().setOperationPerfGroups(operationPerfGroups);
new MockUp<PublishModelFactory>() {
@Mock
DefaultPublishModel createDefaultPublishModel() {
return model;
}
};
publisher.onPolledEvent(new PolledEvent(Collections.emptyList()));
List<LoggingEvent> events = collector.getEvents().stream().filter(e -> {
return DefaultLogPublisher.class.getName().equals(e.getLoggerName());
}).collect(Collectors.toList());
LoggingEvent event = events.get(0);
Assert.assertEquals("\n" + "vertx:\n" + " name eventLoopContext-created\n" + " v 1\n" + "consumer:\n" + " tps latency(ms) max-latency(ms) operation\n" + " rest.OK:\n" + " 10 10.000 0.000 op\n" + " 10 10.000 0.000 \n" + "producer:\n" + " tps latency(ms) max-latency(ms) queue(ms) max-queue(ms) execute(ms) max-execute(ms) operation\n" + " rest.OK:\n" + " 10 10.000 0.000 10.000 0.000 10.000 0.000 op\n" + " 10 10.000 0.000 10.000 0.000 10.000 0.000 \n" + "", event.getMessage());
}
use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups in project incubator-servicecomb-java-chassis by apache.
the class TestPublishUtils method addOperationPerfGroups.
@Test
public void addOperationPerfGroups() {
OperationPerfGroups groups = new OperationPerfGroups();
PublishUtils.addOperationPerfGroups(groups, Const.RESTFUL, op, Utils.createStatusNode(Status.OK.name(), Utils.totalStageNode));
Map<String, OperationPerfGroup> statusMap = groups.getGroups().get(Const.RESTFUL);
OperationPerfGroup group = statusMap.get(Status.OK.name());
PerfInfo perfInfo = group.getSummary().findStage(MeterInvocationConst.STAGE_TOTAL);
Assert.assertEquals(10, perfInfo.getTps());
Assert.assertEquals(1000, perfInfo.calcMsLatency(), 0);
Assert.assertEquals(100000, perfInfo.getMsMaxLatency(), 0);
}
use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups in project incubator-servicecomb-java-chassis by apache.
the class DefaultLogPublisher method printConsumerLog.
protected void printConsumerLog(DefaultPublishModel model, StringBuilder sb) {
OperationPerfGroups consumerPerf = model.getConsumer().getOperationPerfGroups();
if (consumerPerf == null) {
return;
}
sb.append("consumer:\n");
printConsumerPerfLog(consumerPerf, sb);
}
use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups in project incubator-servicecomb-java-chassis by apache.
the class DefaultLogPublisher method printProducerLog.
protected void printProducerLog(DefaultPublishModel model, StringBuilder sb) {
OperationPerfGroups producerPerf = model.getProducer().getOperationPerfGroups();
if (producerPerf == null) {
return;
}
sb.append("producer:\n");
sb.append(" tps latency(ms) max-latency(ms) queue(ms) max-queue(ms) execute(ms) max-execute(ms) operation\n");
for (Map<String, OperationPerfGroup> statusMap : producerPerf.getGroups().values()) {
for (OperationPerfGroup perfGroup : statusMap.values()) {
sb.append(" ").append(perfGroup.getTransport()).append(".").append(perfGroup.getStatus()).append(":\n");
for (OperationPerf operationPerf : perfGroup.getOperationPerfs()) {
printProducerOperationPerf(operationPerf, sb);
}
printProducerOperationPerf(perfGroup.getSummary(), sb);
}
}
}
use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups in project incubator-servicecomb-java-chassis by apache.
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;
}
Aggregations