use of io.prometheus.client.CollectorRegistry in project promregator by promregator.
the class PromregatorApplication method collectorRegistry.
@Bean
public CollectorRegistry collectorRegistry() {
CollectorRegistry cr = CollectorRegistry.defaultRegistry;
DefaultExports.initialize();
return cr;
}
use of io.prometheus.client.CollectorRegistry in project curiostack by curioswitch.
the class MonitoringModule method collectorRegistry.
@Provides
@Singleton
static CollectorRegistry collectorRegistry() {
CollectorRegistry registry = CollectorRegistry.defaultRegistry;
DefaultExports.initialize();
configureLogMetrics();
return registry;
}
use of io.prometheus.client.CollectorRegistry in project resilience4j by resilience4j.
the class CallMeterTest method testInstrumentsFailedCallWithLabels.
@Test
public void testInstrumentsFailedCallWithLabels() throws Exception {
// Given
final CollectorRegistry registry = new CollectorRegistry();
final CallMeter timer = CallMeter.builder().name("some_call").help("Some test help").labelNames("label_1").build().register(registry);
try {
// When
timer.labels("foo").executeRunnable(() -> {
try {
Thread.sleep(50);
throw new SomeAppException("Test Exception");
} catch (InterruptedException e) {
fail();
}
});
} catch (SomeAppException e) {
assertThat(e.getMessage()).isEqualTo("Test Exception");
// ignore
}
// Then
assertThat(registry.getSampleValue("some_call_total", new String[] { "label_1" }, new String[] { "foo" })).isEqualTo(1.0);
assertThat(registry.getSampleValue("some_call_failures_total", new String[] { "label_1" }, new String[] { "foo" })).isEqualTo(1.0);
assertThat(registry.getSampleValue("some_call_latency_count", new String[] { "label_1" }, new String[] { "foo" })).isEqualTo(0.0);
}
use of io.prometheus.client.CollectorRegistry in project resilience4j by resilience4j.
the class CallMeterTest method testInstrumentsSuccessfulCall.
@Test
public void testInstrumentsSuccessfulCall() throws Exception {
// Given
final CollectorRegistry registry = new CollectorRegistry();
final CallMeter timer = CallMeter.ofCollectorRegistry("some_call", "Some help", registry);
// When
timer.executeRunnable(() -> {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
fail();
}
});
// Then
assertThat(registry.getSampleValue("some_call_total", new String[] {}, new String[] {})).isEqualTo(1.0);
assertThat(registry.getSampleValue("some_call_failures_total", new String[] {}, new String[] {})).isEqualTo(0.0);
assertThat(registry.getSampleValue("some_call_latency_count", new String[] {}, new String[] {})).isEqualTo(1.0);
}
use of io.prometheus.client.CollectorRegistry in project resilience4j by resilience4j.
the class CallMeterTest method testInstrumentsSuccessfulCallWithLabels.
@Test
public void testInstrumentsSuccessfulCallWithLabels() throws Exception {
// Given
final CollectorRegistry registry = new CollectorRegistry();
final CallMeter timer = CallMeter.builder().name("some_call").help("Some call help").labelNames("label_1").build().register(registry);
// When
timer.labels("boo").executeRunnable(() -> {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
fail();
}
});
// Then
assertThat(registry.getSampleValue("some_call_total", new String[] { "label_1" }, new String[] { "boo" })).isEqualTo(1.0);
assertThat(registry.getSampleValue("some_call_failures_total", new String[] { "label_1" }, new String[] { "boo" })).isEqualTo(0.0);
assertThat(registry.getSampleValue("some_call_latency_count", new String[] { "label_1" }, new String[] { "boo" })).isEqualTo(1.0);
}
Aggregations