Search in sources :

Example 6 with Meter

use of com.netflix.spectator.api.Meter in project incubator-servicecomb-java-chassis by apache.

the class TestPublishModelFactory method createDefaultPublishModel.

@Test
public void createDefaultPublishModel() throws JsonProcessingException {
    Registry registry = prepareRegistry();
    List<Meter> meters = Lists.newArrayList(registry);
    PublishModelFactory factory = new PublishModelFactory(meters);
    DefaultPublishModel model = factory.createDefaultPublishModel();
    Assert.assertEquals("{\"consumer\":{\"operationPerfGroups\":{\"groups\":{\"rest\":{\"200\":{\"transport\":\"rest\",\"status\":\"200\",\"operationPerfs\":[{\"operation\":\"m.s.o\",\"stages\":{\"total\":{\"tps\":1,\"msTotalTime\":10000.0,\"msMaxLatency\":0.0}}}],\"summary\":{\"operation\":\"\",\"stages\":{\"total\":{\"tps\":1,\"msTotalTime\":10000.0,\"msMaxLatency\":0.0}}}}}}}},\"producer\":{\"operationPerfGroups\":{\"groups\":{\"rest\":{\"200\":{\"transport\":\"rest\",\"status\":\"200\",\"operationPerfs\":[{\"operation\":\"m.s.o\",\"stages\":{\"execution\":{\"tps\":1,\"msTotalTime\":5000.0,\"msMaxLatency\":0.0},\"total\":{\"tps\":1,\"msTotalTime\":10000.0,\"msMaxLatency\":0.0},\"queue\":{\"tps\":1,\"msTotalTime\":5000.0,\"msMaxLatency\":0.0}}}],\"summary\":{\"operation\":\"\",\"stages\":{\"execution\":{\"tps\":1,\"msTotalTime\":5000.0,\"msMaxLatency\":0.0},\"total\":{\"tps\":1,\"msTotalTime\":10000.0,\"msMaxLatency\":0.0},\"queue\":{\"tps\":1,\"msTotalTime\":5000.0,\"msMaxLatency\":0.0}}}}}}}}}", JsonUtils.writeValueAsString(model));
}
Also used : Meter(com.netflix.spectator.api.Meter) DefaultPublishModel(org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel) CompositeRegistry(com.netflix.spectator.api.CompositeRegistry) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Registry(com.netflix.spectator.api.Registry) Test(org.junit.Test)

Example 7 with Meter

use of com.netflix.spectator.api.Meter in project iep by Netflix.

the class BaseServerEndpoint method getMetrics.

private Object getMetrics() {
    List<Object> metrics = new ArrayList<>();
    for (Meter meter : registry) {
        for (Measurement m : meter.measure()) {
            if (Double.isFinite(m.value())) {
                Map<String, Object> datapoint = new LinkedHashMap<>();
                datapoint.put("name", m.id().name());
                datapoint.put("tags", encodeTags(m.id()));
                datapoint.put("timestamp", m.timestamp());
                datapoint.put("value", m.value());
                metrics.add(datapoint);
            }
        }
    }
    return metrics;
}
Also used : Measurement(com.netflix.spectator.api.Measurement) Meter(com.netflix.spectator.api.Meter) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with Meter

use of com.netflix.spectator.api.Meter in project java-chassis by ServiceComb.

the class PrometheusPublisher method describe.

@Override
public List<MetricFamilySamples> describe() {
    List<MetricFamilySamples> familySamples = new ArrayList<>();
    if (globalRegistry == null) {
        return familySamples;
    }
    List<Sample> samples = new ArrayList<>();
    for (Registry registry : globalRegistry.getRegistries()) {
        for (Meter meter : registry) {
            meter.measure().forEach(measurement -> {
                Sample sample = convertMeasurementToSample(measurement);
                samples.add(sample);
            });
        }
    }
    familySamples.add(new MetricFamilySamples("ServiceComb_Metrics", Type.UNTYPED, "ServiceComb Metrics", samples));
    return familySamples;
}
Also used : Meter(com.netflix.spectator.api.Meter) Sample(io.prometheus.client.Collector.MetricFamilySamples.Sample) ArrayList(java.util.ArrayList) CollectorRegistry(io.prometheus.client.CollectorRegistry) GlobalRegistry(org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry) Registry(com.netflix.spectator.api.Registry)

Aggregations

Meter (com.netflix.spectator.api.Meter)8 Measurement (com.netflix.spectator.api.Measurement)5 Registry (com.netflix.spectator.api.Registry)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)3 LinkedHashMap (java.util.LinkedHashMap)2 GlobalRegistry (org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry)2 CompositeRegistry (com.netflix.spectator.api.CompositeRegistry)1 Sample (io.prometheus.client.Collector.MetricFamilySamples.Sample)1 CollectorRegistry (io.prometheus.client.CollectorRegistry)1 ApiResponses (io.swagger.annotations.ApiResponses)1 DeploymentOptions (io.vertx.core.DeploymentOptions)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PolledEvent (org.apache.servicecomb.foundation.metrics.PolledEvent)1 PeriodMeter (org.apache.servicecomb.foundation.metrics.meter.PeriodMeter)1 LogCollector (org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector)1 DefaultPublishModel (org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel)1