Search in sources :

Example 1 with OperationPerfGroup

use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup in project incubator-servicecomb-java-chassis by apache.

the class DefaultLogPublisher method printConsumerPerfLog.

protected void printConsumerPerfLog(OperationPerfGroups consumerPerf, StringBuilder sb) {
    sb.append("  tps     latency(ms) max-latency(ms) operation\n");
    for (Map<String, OperationPerfGroup> statusMap : consumerPerf.getGroups().values()) {
        for (OperationPerfGroup perfGroup : statusMap.values()) {
            sb.append("  ").append(perfGroup.getTransport()).append(".").append(perfGroup.getStatus()).append(":\n");
            for (OperationPerf operationPerf : perfGroup.getOperationPerfs()) {
                printConsumerOperationPerf(operationPerf, sb);
            }
            printConsumerOperationPerf(perfGroup.getSummary(), sb);
        }
    }
}
Also used : OperationPerf(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup)

Example 2 with OperationPerfGroup

use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup 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());
}
Also used : Expectations(mockit.Expectations) LoggingEvent(org.apache.log4j.spi.LoggingEvent) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup) CompositeRegistry(com.netflix.spectator.api.CompositeRegistry) Expectations(mockit.Expectations) ArchaiusUtils(org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils) DefaultPublishModel(org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel) MeterInvocationConst(org.apache.servicecomb.metrics.core.meter.invocation.MeterInvocationConst) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo) VertxImplEx(io.vertx.core.impl.VertxImplEx) MetricsBootstrapConfig(org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig) EventBus(com.google.common.eventbus.EventBus) OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups) VertxUtils(org.apache.servicecomb.foundation.vertx.VertxUtils) After(org.junit.After) Mock(mockit.Mock) PolledEvent(org.apache.servicecomb.foundation.metrics.PolledEvent) OperationPerf(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf) Status(javax.ws.rs.core.Response.Status) Before(org.junit.Before) LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) MockUp(mockit.MockUp) Const(org.apache.servicecomb.core.Const) LoggingEvent(org.apache.log4j.spi.LoggingEvent) Test(org.junit.Test) Collectors(java.util.stream.Collectors) List(java.util.List) Holder(javax.xml.ws.Holder) Assert(org.junit.Assert) Collections(java.util.Collections) Mocked(mockit.Mocked) OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups) PolledEvent(org.apache.servicecomb.foundation.metrics.PolledEvent) OperationPerf(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf) DefaultPublishModel(org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel) MockUp(mockit.MockUp) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup) Test(org.junit.Test)

Example 3 with OperationPerfGroup

use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup 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);
}
Also used : OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup) Test(org.junit.Test)

Example 4 with OperationPerfGroup

use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup in project java-chassis by ServiceComb.

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);
    Integer[] latencyDistribution = group.getSummary().getLatencyDistribution();
    Assert.assertEquals(10, perfInfo.getTps(), 0);
    Assert.assertEquals(1000, perfInfo.calcMsLatency(), 0);
    Assert.assertEquals(100000, perfInfo.getMsMaxLatency(), 0);
    Assert.assertEquals(2, latencyDistribution.length);
    Assert.assertEquals(1, latencyDistribution[0].intValue());
    Assert.assertEquals(2, latencyDistribution[1].intValue());
}
Also used : OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups) PerfInfo(org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup) Test(org.junit.Test)

Example 5 with OperationPerfGroup

use of org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup in project java-chassis by ServiceComb.

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" + " simple:\n" + "  status      tps      latency            ").append(latencyDistributionHeader).append("operation\n");
    StringBuilder detailsBuilder = new StringBuilder();
    // print sample
    for (Map<String, OperationPerfGroup> statusMap : consumerPerf.getGroups().values()) {
        for (OperationPerfGroup perfGroup : statusMap.values()) {
            // append sample
            sb.append(printSamplePerf(perfGroup));
            // append details
            detailsBuilder.append(printConsumerDetailsPerf(perfGroup));
        }
    }
    sb.append(" details:\n").append(detailsBuilder);
}
Also used : OperationPerfGroups(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups) OperationPerfGroup(org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup)

Aggregations

OperationPerfGroup (org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup)11 OperationPerfGroups (org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups)8 OperationPerf (org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf)6 PerfInfo (org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo)4 Test (org.junit.Test)4 EventBus (com.google.common.eventbus.EventBus)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Status (javax.ws.rs.core.Response.Status)2 Expectations (mockit.Expectations)2 Mock (mockit.Mock)2 MockUp (mockit.MockUp)2 Mocked (mockit.Mocked)2 LoggingEvent (org.apache.log4j.spi.LoggingEvent)2 Const (org.apache.servicecomb.core.Const)2 MetricsBootstrapConfig (org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig)2 PolledEvent (org.apache.servicecomb.foundation.metrics.PolledEvent)2 ArchaiusUtils (org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils)2