use of org.hyperledger.besu.metrics.Observation in project teku by ConsenSys.
the class RocksDbStatsTest method shouldNotCrashIfMetricsRequestedAfterClose.
@Test
void shouldNotCrashIfMetricsRequestedAfterClose() throws Exception {
final ObservableMetricsSystem metricsSystem = new PrometheusMetricsSystem(Set.of(TekuMetricCategory.STORAGE_HOT_DB), true);
try (RocksDbStats stats = new RocksDbStats(metricsSystem, TekuMetricCategory.STORAGE_HOT_DB)) {
stats.registerMetrics(database);
}
when(database.getLongProperty(any())).thenThrow(new IllegalStateException("Database shutdown"));
final List<Observation> metrics = metricsSystem.streamObservations().collect(Collectors.toList());
assertThat(metrics).isNotEmpty();
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest 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", 1L, emptyList()));
counter.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 OpenTelemetryMetricsSystemTest method shouldCreateObservationsFromTimerWithLabels.
@Test
public void shouldCreateObservationsFromTimerWithLabels() {
final LabelledMetric<OperationTimer> timer = metricsSystem.createLabelledTimer(RPC, "request", "Some help", "methodName");
// noinspection EmptyTryBlock
try (final OperationTimer.TimingContext ignored = timer.labels("method").startTimer()) {
}
// noinspection EmptyTryBlock
try (final OperationTimer.TimingContext ignored = timer.labels("method").startTimer()) {
}
// noinspection EmptyTryBlock
try (final OperationTimer.TimingContext ignored = timer.labels("method").startTimer()) {
}
// noinspection EmptyTryBlock
try (final OperationTimer.TimingContext ignored = timer.labels("method").startTimer()) {
}
assertThat(metricsSystem.streamObservations()).usingElementComparator(// We don't know how long it will actually take.
IGNORE_VALUES).containsExactlyInAnyOrder(new Observation(RPC, "request", null, singletonList("method")));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest method shouldCreateObservationFromGauge.
@Test
public void shouldCreateObservationFromGauge() {
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().metricCategories(ImmutableSet.of(BesuMetricCategory.RPC)).enabled(true).protocol(OPENTELEMETRY).build();
final ObservableMetricsSystem localMetricSystem = MetricsSystemFactory.create(metricsConfiguration);
localMetricSystem.createGauge(RPC, "myValue", "Help", () -> 7.0);
assertThat(localMetricSystem.streamObservations()).containsExactlyInAnyOrder(new Observation(RPC, "myValue", 7.0, emptyList()));
}
use of org.hyperledger.besu.metrics.Observation in project besu by hyperledger.
the class OpenTelemetryMetricsSystemTest method shouldCreateObservationsFromTimer.
@Test
public void shouldCreateObservationsFromTimer() {
final OperationTimer timer = metricsSystem.createTimer(RPC, "request", "Some help");
final OperationTimer.TimingContext context = timer.startTimer();
context.stopTimer();
assertThat(metricsSystem.streamObservations()).usingElementComparator(IGNORE_VALUES).containsExactlyInAnyOrder(new Observation(RPC, "request", null, Collections.emptyList()));
}
Aggregations