use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest method shouldCreateLabelledGauge.
@Test
public void shouldCreateLabelledGauge() {
LabelledGauge labelledGauge = metricsSystem.createLabelledGauge(RPC, "gaugeName", "help", "a", "b");
labelledGauge.labels(() -> 1.0, "a1", "b1");
labelledGauge.labels(() -> 11.0, "a2", "b2");
labelledGauge.labels(() -> 21.0, "a3", "b3");
assertThat(metricsSystem.streamObservations()).containsExactlyInAnyOrder(new Observation(RPC, "gaugeName", 1.0, List.of("a1", "b1")), new Observation(RPC, "gaugeName", 11.0, List.of("a2", "b2")), new Observation(RPC, "gaugeName", 21.0, List.of("a3", "b3")));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest 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", 5L, emptyList()));
counter.inc(6);
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 11L, emptyList()));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest method shouldOnlyObserveEnabledMetrics.
@Test
public void shouldOnlyObserveEnabledMetrics() {
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().metricCategories(ImmutableSet.of(BesuMetricCategory.RPC)).enabled(true).protocol(OPENTELEMETRY).build();
final ObservableMetricsSystem localMetricSystem = MetricsSystemFactory.create(metricsConfiguration);
// do a category we are not watching
final LabelledMetric<Counter> counterN = localMetricSystem.createLabelledCounter(NETWORK, "ABC", "Not that kind of network", "show");
assertThat(counterN).isSameAs(NoOpMetricsSystem.NO_OP_LABELLED_1_COUNTER);
counterN.labels("show").inc();
assertThat(localMetricSystem.streamObservations()).isEmpty();
// do a category we are watching
final LabelledMetric<Counter> counterR = localMetricSystem.createLabelledCounter(RPC, "name", "Not useful", "method");
assertThat(counterR).isNotSameAs(NoOpMetricsSystem.NO_OP_LABELLED_1_COUNTER);
counterR.labels("op").inc();
assertThat(localMetricSystem.streamObservations()).containsExactly(new Observation(RPC, "name", (long) 1, singletonList("op")));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest 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", 1L, emptyList()));
counter2.labels().inc();
assertThat(metricsSystem.streamObservations()).containsExactly(new Observation(PEERS, "connected", 2L, emptyList()));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldCreateObservationFromGauge.
@Test
public void shouldCreateObservationFromGauge() {
metricsSystem.createGauge(JVM, "myValue", "Help", () -> 7.0);
assertThat(metricsSystem.streamObservations()).containsExactlyInAnyOrder(new Observation(JVM, "myValue", 7.0, emptyList()));
}
Aggregations