Search in sources :

Example 1 with MetricRegistryInfo

use of org.apache.ratis.metrics.MetricRegistryInfo in project incubator-ratis by apache.

the class RaftBasicTests method getStatemachineGaugeWithName.

private static Gauge getStatemachineGaugeWithName(RaftServer.Division server, String gaugeName) {
    MetricRegistryInfo info = new MetricRegistryInfo(server.getMemberId().toString(), RATIS_APPLICATION_NAME_METRICS, RATIS_STATEMACHINE_METRICS, RATIS_STATEMACHINE_METRICS_DESC);
    Optional<RatisMetricRegistry> metricRegistry = MetricRegistries.global().get(info);
    Assert.assertTrue(metricRegistry.isPresent());
    RatisMetricRegistry ratisStateMachineMetricRegistry = metricRegistry.get();
    SortedMap<String, Gauge> gaugeMap = ratisStateMachineMetricRegistry.getGauges((s, metric) -> s.contains(gaugeName));
    return gaugeMap.get(gaugeMap.firstKey());
}
Also used : RatisMetricRegistry(org.apache.ratis.metrics.RatisMetricRegistry) MetricRegistryInfo(org.apache.ratis.metrics.MetricRegistryInfo) Gauge(com.codahale.metrics.Gauge)

Example 2 with MetricRegistryInfo

use of org.apache.ratis.metrics.MetricRegistryInfo in project incubator-ratis by apache.

the class RaftSnapshotBaseTest method getTakeSnapshotTimer.

private static Timer getTakeSnapshotTimer(RaftServer.Division leader) {
    MetricRegistryInfo info = new MetricRegistryInfo(leader.getMemberId().toString(), RATIS_APPLICATION_NAME_METRICS, RATIS_STATEMACHINE_METRICS, RATIS_STATEMACHINE_METRICS_DESC);
    Optional<RatisMetricRegistry> opt = MetricRegistries.global().get(info);
    Assert.assertTrue(opt.isPresent());
    RatisMetricRegistry metricRegistry = opt.get();
    Assert.assertNotNull(metricRegistry);
    return metricRegistry.timer(STATEMACHINE_TAKE_SNAPSHOT_TIMER);
}
Also used : RatisMetricRegistry(org.apache.ratis.metrics.RatisMetricRegistry) MetricRegistryInfo(org.apache.ratis.metrics.MetricRegistryInfo)

Example 3 with MetricRegistryInfo

use of org.apache.ratis.metrics.MetricRegistryInfo in project incubator-ratis by apache.

the class TestRaftSnapshotWithGrpc method verifyInstallSnapshotMetric.

@Override
protected void verifyInstallSnapshotMetric(RaftServer.Division leader) {
    MetricRegistryInfo info = new MetricRegistryInfo(leader.getMemberId().toString(), "ratis_grpc", "log_appender", "Metrics for Ratis Grpc Log Appender");
    Optional<RatisMetricRegistry> metricRegistry = MetricRegistries.global().get(info);
    Assert.assertTrue(metricRegistry.isPresent());
    Counter installSnapshotCounter = metricRegistry.get().counter("num_install_snapshot");
    Assert.assertNotNull(installSnapshotCounter);
    Assert.assertTrue(installSnapshotCounter.getCount() >= 1);
}
Also used : Counter(com.codahale.metrics.Counter) RatisMetricRegistry(org.apache.ratis.metrics.RatisMetricRegistry) MetricRegistryInfo(org.apache.ratis.metrics.MetricRegistryInfo)

Aggregations

MetricRegistryInfo (org.apache.ratis.metrics.MetricRegistryInfo)3 RatisMetricRegistry (org.apache.ratis.metrics.RatisMetricRegistry)3 Counter (com.codahale.metrics.Counter)1 Gauge (com.codahale.metrics.Gauge)1