use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.
the class RestMetricsResource method testTimerMetrics.
@Test
public void testTimerMetrics() throws Exception {
RestClient client = SERVER_TEST.rest().create();
RestMetricsClient metricsClient = client.metrics();
// this is a histogram of write times
String metricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_statistics_store_times";
int NUM_PUTS = 10;
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor", metricName);
checkRule(body, "vendor_" + metricName, (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isZero();
});
}
// put some entries then check that the stats were updated
RestCacheClient cache = client.cache(SERVER_TEST.getMethodName());
for (int i = 0; i < NUM_PUTS; i++) {
RestResponse putResp = sync(cache.put("k" + i, "v" + i));
assertEquals(204, putResp.getStatus());
}
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor", metricName);
checkRule(body, "vendor_" + metricName, (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isPositive();
});
}
}
use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.
the class RestMetricsResource method testBaseAndVendorMetrics.
@Test
public void testBaseAndVendorMetrics() throws Exception {
RestMetricsClient metricsClient = SERVER_TEST.rest().create().metrics();
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
// that is the default
checkIsPrometheus(response.contentType());
String body = response.getBody();
checkRule(body, "base_classloader_loadedClasses_count", (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isPositive();
});
checkRule(body, "vendor_memoryPool_Metaspace_usage_bytes", (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isPositive();
});
}
}
use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.
the class RestMetricsResource method testMetrics.
@Test
public void testMetrics() throws Exception {
RestClient client = SERVER_TEST.rest().create();
RestMetricsClient metricsClient = client.metrics();
String metricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_statistics_stores";
int NUM_PUTS = 10;
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor", metricName);
checkRule(body, "vendor_" + metricName, (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isZero();
});
}
// put some entries then check that the stats were updated
RestCacheClient cache = client.cache(SERVER_TEST.getMethodName());
for (int i = 0; i < NUM_PUTS; i++) {
RestResponse putResp = sync(cache.put("k" + i, "v" + i));
assertEquals(204, putResp.getStatus());
}
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor", metricName);
checkRule(body, "vendor_" + metricName, (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isEqualTo(10.0);
});
}
// delete cache and check that the metric is gone
sync(client.cache(SERVER_TEST.getMethodName()).delete());
try (RestResponse response = sync(metricsClient.metrics())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor");
// metric is not present anymore:
assertThat(body).doesNotContain(metricName);
}
}
use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.
the class RestMetricsResource method testOpenMetrics.
@Test
public void testOpenMetrics() {
RestMetricsClient metricsClient = SERVER_TEST.rest().create().metrics();
String metricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_statistics_stores";
try (RestResponse response = sync(metricsClient.metrics(true))) {
assertEquals(200, response.getStatus());
checkIsOpenmetrics(response.contentType());
String metricsText = response.getBody();
assertTrue(metricsText.contains("# TYPE vendor_" + metricName + " gauge\n"));
}
}
use of org.infinispan.client.rest.RestMetricsClient in project infinispan by infinispan.
the class RestMetricsResource method testMetricsMetadata.
@Test
public void testMetricsMetadata() throws Exception {
RestClient client = SERVER_TEST.rest().create();
RestMetricsClient metricsClient = client.metrics();
String metricName = "cache_manager_default_cache_" + SERVER_TEST.getMethodName() + "_statistics_stores";
try (RestResponse response = sync(metricsClient.metricsMetadata())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor", metricName);
checkRule(body, "vendor_" + metricName, (stringValue) -> {
double parsed = Double.parseDouble(stringValue);
assertThat(parsed).isZero();
});
}
// delete cache and check that the metric is gone
sync(client.cache(SERVER_TEST.getMethodName()).delete());
try (RestResponse response = sync(metricsClient.metricsMetadata())) {
assertEquals(200, response.getStatus());
checkIsPrometheus(response.contentType());
String body = response.getBody();
assertThat(body).contains("base", "vendor");
// metric is not present anymore:
assertThat(body).doesNotContain(metricName);
}
}
Aggregations