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