use of io.pravega.shared.metrics.Counter in project pravega by pravega.
the class ControllerPrometheusTest method testPrometheusMetrics.
@Test
public void testPrometheusMetrics() throws Exception {
MetricsProvider.initialize(MetricsConfig.builder().with(MetricsConfig.ENABLE_STATISTICS, true).with(MetricsConfig.ENABLE_PROMETHEUS, true).with(MetricsConfig.METRICS_PREFIX, "promtestcontroller").build());
@Cleanup StatsProvider statsProvider = MetricsProvider.getMetricsProvider();
statsProvider.start();
@Cleanup ControllerServiceStarter starter = new ControllerServiceStarter(createControllerServiceConfig(), storeClient, null);
starter.startAsync();
starter.awaitRunning();
Counter c = statsProvider.createStatsLogger("promtest").createCounter("promtestcounter");
c.add(1);
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:" + this.restPort + "/prometheus")).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
assertTrue(response.body().lines().anyMatch(x -> Pattern.matches("promtestcounter.*1\\.0", x)));
starter.stopAsync();
starter.awaitTerminated();
}
use of io.pravega.shared.metrics.Counter in project pravega by pravega.
the class PrometheusTest method testPrometheusMetrics.
@Test
public void testPrometheusMetrics() throws Exception {
@Cleanup StatsProvider statsProvider = MetricsProvider.getMetricsProvider();
statsProvider.start();
Counter c = statsProvider.createStatsLogger("promtest").createCounter("promtestcounter");
c.add(1);
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://localhost:" + this.restPort + "/prometheus")).build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
assertTrue(response.body().lines().anyMatch(x -> Pattern.matches("promtestcounter.*1\\.0", x)));
}
Aggregations