use of org.hyperledger.besu.plugin.services.metrics.LabelledGauge in project teku by ConsenSys.
the class CachingTaskQueue method startMetrics.
public void startMetrics() {
final LabelledGauge taskQueueMetrics = metricsSystem.createLabelledGauge(TekuMetricCategory.STORAGE, metricsPrefix + "_tasks", "Labelled task queue metrics", "status");
taskQueueMetrics.labels(pendingTasks::size, "requested");
taskQueueMetrics.labels(activeTasks::get, "active");
taskQueueMetrics.labels(queuedTasks::size, "queued");
metricsSystem.createIntegerGauge(TekuMetricCategory.STORAGE, metricsPrefix + "_cache_size", "Number of checkpoint states held in the in-memory store", cache::size);
}
use of org.hyperledger.besu.plugin.services.metrics.LabelledGauge in project besu by hyperledger.
the class PrometheusMetricsSystemTest method shouldNotUseSameLabelsTwiceOnSameGauge.
@Test
public void shouldNotUseSameLabelsTwiceOnSameGauge() {
final LabelledGauge gauge = metricsSystem.createLabelledGauge(PEERS, "test", "test help", "a", "b", "c");
final double value1 = 1.0;
gauge.labels(() -> value1, "a1", "b1", "c1");
assertThatThrownBy(() -> gauge.labels(() -> value1, "a1", "b1", "c1")).isInstanceOf(IllegalArgumentException.class);
}
use of org.hyperledger.besu.plugin.services.metrics.LabelledGauge 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.plugin.services.metrics.LabelledGauge 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.plugin.services.metrics.LabelledGauge in project teku by ConsenSys.
the class PeerManagerTest method shouldCreatePeerTypeMetrics.
@Test
public void shouldCreatePeerTypeMetrics() {
final MetricsSystem metricsSystem = mock(MetricsSystem.class);
final LabelledGauge gauge = mock(LabelledGauge.class);
when(metricsSystem.createLabelledGauge(eq(TekuMetricCategory.LIBP2P), eq("connected_peers_current"), any(), any())).thenReturn(gauge);
new PeerManager(metricsSystem, reputationManager, Collections.emptyList(), Collections.emptyList(), peerId -> 0.0);
for (PeerClientType type : PeerClientType.values()) {
verify(gauge).labels(any(), eq(type.getDisplayName()));
}
}
Aggregations