Search in sources :

Example 16 with Observation

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()));
}
Also used : Counter(org.hyperledger.besu.plugin.services.metrics.Counter) Observation(org.hyperledger.besu.metrics.Observation) Test(org.junit.Test)

Example 17 with Observation

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()));
}
Also used : Counter(org.hyperledger.besu.plugin.services.metrics.Counter) Observation(org.hyperledger.besu.metrics.Observation) Test(org.junit.Test)

Example 18 with Observation

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")));
}
Also used : Observation(org.hyperledger.besu.metrics.Observation) LabelledGauge(org.hyperledger.besu.plugin.services.metrics.LabelledGauge) Test(org.junit.Test)

Example 19 with Observation

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")));
}
Also used : Counter(org.hyperledger.besu.plugin.services.metrics.Counter) Observation(org.hyperledger.besu.metrics.Observation) Test(org.junit.Test)

Example 20 with Observation

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()));
}
Also used : Counter(org.hyperledger.besu.plugin.services.metrics.Counter) Observation(org.hyperledger.besu.metrics.Observation) Test(org.junit.Test)

Aggregations

Observation (org.hyperledger.besu.metrics.Observation)20 Test (org.junit.Test)18 Counter (org.hyperledger.besu.plugin.services.metrics.Counter)10 ObservableMetricsSystem (org.hyperledger.besu.metrics.ObservableMetricsSystem)4 OperationTimer (org.hyperledger.besu.plugin.services.metrics.OperationTimer)4 MetricsConfiguration (org.hyperledger.besu.metrics.prometheus.MetricsConfiguration)2 LabelledGauge (org.hyperledger.besu.plugin.services.metrics.LabelledGauge)2 DoubleHistogramPointData (io.opentelemetry.sdk.metrics.data.DoubleHistogramPointData)1 DoublePointData (io.opentelemetry.sdk.metrics.data.DoublePointData)1 DoubleSummaryPointData (io.opentelemetry.sdk.metrics.data.DoubleSummaryPointData)1 LongPointData (io.opentelemetry.sdk.metrics.data.LongPointData)1 PointData (io.opentelemetry.sdk.metrics.data.PointData)1 ArrayList (java.util.ArrayList)1 BesuMetricCategory (org.hyperledger.besu.metrics.BesuMetricCategory)1 StandardMetricCategory (org.hyperledger.besu.metrics.StandardMetricCategory)1 PrometheusMetricsSystem (org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem)1 MetricCategory (org.hyperledger.besu.plugin.services.metrics.MetricCategory)1 Test (org.junit.jupiter.api.Test)1