Search in sources :

Example 1 with LabelledGauge

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

Example 2 with LabelledGauge

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

Example 3 with LabelledGauge

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

Example 4 with LabelledGauge

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

Example 5 with LabelledGauge

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()));
    }
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) LabelledGauge(org.hyperledger.besu.plugin.services.metrics.LabelledGauge) Test(org.junit.jupiter.api.Test)

Aggregations

LabelledGauge (org.hyperledger.besu.plugin.services.metrics.LabelledGauge)5 Test (org.junit.Test)3 Observation (org.hyperledger.besu.metrics.Observation)2 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 MetricsSystem (org.hyperledger.besu.plugin.services.MetricsSystem)1 Test (org.junit.jupiter.api.Test)1