Search in sources :

Example 1 with MeasurementGroupConfig

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

the class PublishModelFactory method createMeasurementGroupConfig.

protected MeasurementGroupConfig createMeasurementGroupConfig() {
    MeasurementGroupConfig groupConfig = new MeasurementGroupConfig();
    groupConfig.addGroup(MeterInvocationConst.INVOCATION_NAME, MeterInvocationConst.TAG_ROLE, MeterInvocationConst.TAG_TRANSPORT, MeterInvocationConst.TAG_OPERATION, MeterInvocationConst.TAG_STATUS, MeterInvocationConst.TAG_STAGE, MeterInvocationConst.TAG_STATISTIC);
    return groupConfig;
}
Also used : MeasurementGroupConfig(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig)

Example 2 with MeasurementGroupConfig

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

the class PublishModelFactory method createMeasurementTree.

protected MeasurementTree createMeasurementTree(List<Meter> meters) {
    MeasurementGroupConfig groupConfig = createMeasurementGroupConfig();
    MeasurementTree tree = new MeasurementTree();
    tree.from(meters.iterator(), groupConfig);
    return tree;
}
Also used : MeasurementTree(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree) MeasurementGroupConfig(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig)

Example 3 with MeasurementGroupConfig

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

the class TestDefaultMetricsInitializer method producerInvocation.

@Test
public void producerInvocation(@Mocked InvocationFinishEvent event) {
    new Expectations() {

        {
            invocation.isConsumer();
            result = false;
            invocation.getInvocationType();
            result = InvocationType.PRODUCER;
            invocation.getRealTransportName();
            result = Const.RESTFUL;
            invocation.getMicroserviceQualifiedName();
            result = "m.s.o";
            invocation.getStartTime();
            result = 1;
            invocation.getStartExecutionTime();
            result = 3;
            event.getNanoCurrent();
            result = 10;
            event.getInvocation();
            result = invocation;
        }
    };
    eventBus.post(event);
    eventBus.post(event);
    MeasurementTree tree = new MeasurementTree();
    tree.from(globalRegistry.iterator(), new MeasurementGroupConfig(MeterInvocationConst.INVOCATION_NAME));
    Assert.assertEquals("[Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=execution:statistic=count:status=0:transport=rest,0,2.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=execution:statistic=totalTime:status=0:transport=rest,0,14.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=total:statistic=count:status=0:transport=rest,0,2.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=total:statistic=totalTime:status=0:transport=rest,0,18.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=queue:statistic=count:status=0:transport=rest,0,2.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=PRODUCER:stage=queue:statistic=totalTime:status=0:transport=rest,0,4.0)]", tree.findChild(MeterInvocationConst.INVOCATION_NAME).getMeasurements().toString());
}
Also used : Expectations(mockit.Expectations) MeasurementTree(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree) MeasurementGroupConfig(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig) Test(org.junit.Test)

Example 4 with MeasurementGroupConfig

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

the class TestDefaultMetricsInitializer method consumerInvocation.

@Test
public void consumerInvocation(@Mocked InvocationFinishEvent event) {
    new Expectations() {

        {
            invocation.isConsumer();
            result = true;
            invocation.getInvocationType();
            result = InvocationType.CONSUMER;
            invocation.getRealTransportName();
            result = Const.RESTFUL;
            invocation.getMicroserviceQualifiedName();
            result = "m.s.o";
            invocation.getStartTime();
            result = 1;
            event.getInvocation();
            result = invocation;
            event.getNanoCurrent();
            result = 10;
        }
    };
    eventBus.post(event);
    eventBus.post(event);
    MeasurementTree tree = new MeasurementTree();
    tree.from(globalRegistry.iterator(), new MeasurementGroupConfig(MeterInvocationConst.INVOCATION_NAME));
    Assert.assertEquals("[Measurement(servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=count:status=0:transport=rest,0,2.0), " + "Measurement(servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=totalTime:status=0:transport=rest,0,18.0)]", tree.findChild(MeterInvocationConst.INVOCATION_NAME).getMeasurements().toString());
}
Also used : Expectations(mockit.Expectations) MeasurementTree(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree) MeasurementGroupConfig(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig) Test(org.junit.Test)

Example 5 with MeasurementGroupConfig

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

the class PublishModelFactory method createMeasurementTree.

protected MeasurementTree createMeasurementTree(List<Meter> meters) {
    MeasurementGroupConfig groupConfig = createMeasurementGroupConfig();
    MeasurementTree tree = new MeasurementTree();
    tree.from(meters.iterator(), groupConfig);
    return tree;
}
Also used : MeasurementTree(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree) MeasurementGroupConfig(org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig)

Aggregations

MeasurementGroupConfig (org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig)9 MeasurementTree (org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree)7 Expectations (mockit.Expectations)5 Test (org.junit.Test)5 DefaultTagFinder (org.apache.servicecomb.foundation.metrics.publish.spectator.DefaultTagFinder)1