use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testThreadPoolQueueSize.
/**
* test thread pool queue size
*/
@Test
public void testThreadPoolQueueSize() {
Metric metric = fetchWithNameAndMethod("rpc.bolt.threadpool.queue.size", "");
Collection<Measurement> measurements = metric.measure().measurements();
assertTrue(measurements.size() == 1);
for (Measurement measurement : measurements) {
assertEquals(0, ((Number) measurement.value()).intValue());
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testThreadPoolIdleCount.
/**
* test thread pool idle count
*/
@Test
public void testThreadPoolIdleCount() {
// sync invoke some time
for (int i = 0; i < 3; i++) {
try {
lookoutService.saySync("lookout_sync");
} catch (Exception e) {
LOGGER.error("sync error", e);
}
}
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
Metric metric = fetchWithNameAndMethod("rpc.bolt.threadpool.idle.count", "");
Collection<Measurement> measurements = metric.measure().measurements();
assertTrue(measurements.size() == 1);
for (Measurement measurement : measurements) {
assertEquals(3, ((Number) measurement.value()).intValue());
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testThreadPoolActiveCount.
/**
* test thread pool active count
*
* @throws Exception Exception
*/
@Test
public void testThreadPoolActiveCount() throws Exception {
Metric metric = fetchWithNameAndMethod("rpc.bolt.threadpool.active.count", "");
Collection<Measurement> measurements = metric.measure().measurements();
assertTrue(measurements.size() == 1);
for (Measurement measurement : measurements) {
assertEquals(0, ((Number) measurement.value()).intValue());
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RestLookoutTest method afterMethod.
@After
public void afterMethod() {
// clear all metrics now
Registry currentRegistry = Lookout.registry();
Iterator<Metric> itar = currentRegistry.iterator();
while (itar.hasNext()) {
Metric metric = itar.next();
Id id = metric.id();
currentRegistry.removeMetric(id);
}
if (providerConfig != null) {
providerConfig.unExport();
}
if (consumerConfig != null) {
consumerConfig.unRefer();
}
if (serverConfig != null) {
serverConfig.destroy();
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testCallbackServiceStats.
/**
* test provider service stats
*/
@Test
public void testCallbackServiceStats() {
// callback
for (int i = 0; i < 5; i++) {
try {
lookoutService.sayCallback("lookout_callback");
} catch (Exception e) {
LOGGER.error("callback error", e);
}
}
for (int i = 0; i < 10; i++) {
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
}
if (onReturn.getSize() == 5) {
break;
}
}
String methodName = "sayCallback";
Metric metric = fetchWithNameAndMethod("rpc.provider.service.stats", methodName);
if (metric == null) {
Assert.fail("no provider metric was found null");
}
assertMethod(metric, true, 5, methodName, 0, 0);
Metric consumerMetric = fetchWithNameAndMethod("rpc.consumer.service.stats", methodName);
if (consumerMetric == null) {
Assert.fail("no consumer eetric was found null");
}
assertMethod(consumerMetric, false, 5, methodName, 2045, 720);
}
Aggregations