use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldIncrementCounterBySpecifiedAmount.
@Test
public void shouldIncrementCounterBySpecifiedAmount() {
final Counter counter = metricsSystem.createCounter(PEERS, "connected", "Some help string");
counter.inc(5);
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 5.0, emptyList()));
counter.inc(6);
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 11.0, emptyList()));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldCreateObservationFromCounter.
@Test
public void shouldCreateObservationFromCounter() {
final Counter counter = metricsSystem.createCounter(PEERS, "connected", "Some help string");
counter.inc();
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 1.0, emptyList()));
counter.inc();
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 2.0, emptyList()));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldCreateSeparateObservationsForEachLabelledGaugeValue.
@Test
public void shouldCreateSeparateObservationsForEachLabelledGaugeValue() {
final LabelledGauge gauge = metricsSystem.createLabelledGauge(PEERS, "test", "test help", "a", "b", "c");
final double value1 = 1.0;
final double value2 = 11.0;
gauge.labels(() -> value1, "a1", "b1", "c1");
gauge.labels(() -> value2, "a2", "b2", "c2");
assertThat(metricsSystem.streamObservations()).containsExactlyInAnyOrder(new Observation(PEERS, "test", 1.0, List.of("a1", "b1", "c1")), new Observation(PEERS, "test", 11.0, List.of("a2", "b2", "c2")));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldCreateSeparateObservationsForEachCounterLabelValue.
@Test
public void shouldCreateSeparateObservationsForEachCounterLabelValue() {
final LabelledMetric<Counter> counter = metricsSystem.createLabelledCounter(PEERS, "connected", "Some help string", "labelName");
counter.labels("value1").inc();
counter.labels("value2").inc();
counter.labels("value1").inc();
assertThat(metricsSystem.streamObservations()).containsExactlyInAnyOrder(new Observation(PEERS, "connected", 2.0, singletonList("value1")), new Observation(PEERS, "connected", 1.0, singletonList("value2")));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldHandleDuplicateCounterCreation.
@Test
public void shouldHandleDuplicateCounterCreation() {
final LabelledMetric<Counter> counter1 = metricsSystem.createLabelledCounter(PEERS, "connected", "Some help string");
final LabelledMetric<Counter> counter2 = metricsSystem.createLabelledCounter(PEERS, "connected", "Some help string");
assertThat(counter1).isEqualTo(counter2);
counter1.labels().inc();
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 1.0, emptyList()));
counter2.labels().inc();
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 2.0, emptyList()));
}
Aggregations