use of org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry in project java-chassis by ServiceComb.
the class OsMetersInitializer method init.
@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
if (!isOsLinux) {
LOGGER.info("only support linux os to collect cpu and net info");
return;
}
Registry registry = globalRegistry.getDefaultRegistry();
osMeter = new OsMeter(registry);
SpectatorUtils.registerMeter(registry, osMeter);
}
use of org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry in project java-chassis by ServiceComb.
the class TestMetricsRestPublisher method measure_normal.
@Test
public void measure_normal() {
Clock clock = new ManualClock();
GlobalRegistry globalRegistry = new GlobalRegistry();
Registry registry = new DefaultRegistry(clock);
registry.timer(registry.createId("name", "t1", "v1", "t2", "v2"));
globalRegistry.add(registry);
EventBus eventBus = new EventBus();
publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
Map<String, Double> result = publisher.measure();
Assert.assertEquals(2, result.size());
Assert.assertEquals(0, result.get("name(statistic=count,t1=v1,t2=v2)"), 0);
Assert.assertEquals(0, result.get("name(statistic=totalTime,t1=v1,t2=v2)"), 0);
}
use of org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry in project java-chassis by ServiceComb.
the class MetricsRestPublisher method measure.
@ApiResponses({ @ApiResponse(code = 400, response = String.class, message = "illegal request content") })
@GET
@Path("/")
public Map<String, Double> measure() {
Map<String, Double> measurements = new LinkedHashMap<>();
if (globalRegistry == null) {
return measurements;
}
StringBuilder sb = new StringBuilder();
for (Registry registry : globalRegistry.getRegistries()) {
for (Meter meter : registry) {
meter.measure().forEach(measurement -> {
String key = idToString(measurement.id(), sb);
measurements.put(key, measurement.value());
});
}
}
return measurements;
}
use of org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry in project java-chassis by ServiceComb.
the class MetricsBootListener method onAfterRegistry.
@Override
public void onAfterRegistry(BootEvent event) {
slowInvocationLogger = new SlowInvocationLogger(event.getScbEngine());
metricsBootstrap.start(new GlobalRegistry(), EventManager.getEventBus());
}
use of org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry in project java-chassis by ServiceComb.
the class VertxMetersInitializer method init.
@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
Registry registry = globalRegistry.getDefaultRegistry();
Id endpointsId = registry.createId(VERTX_ENDPOINTS);
VertxEndpointsMeter clientMeter = new HttpClientEndpointsMeter(endpointsId.withTag(ENDPOINTS_TYPE, ENDPOINTS_CLINET), SharedVertxFactory.getMetricsFactory().getVertxMetrics().getClientEndpointMetricManager().getClientEndpointMetricMap());
SpectatorUtils.registerMeter(registry, clientMeter);
VertxEndpointsMeter serverMeter = new ServerEndpointsMeter(endpointsId.withTag(ENDPOINTS_TYPE, ENDPOINTS_SERVER), SharedVertxFactory.getMetricsFactory().getVertxMetrics().getServerEndpointMetricMap());
SpectatorUtils.registerMeter(registry, serverMeter);
}
Aggregations