use of org.opendaylight.infrautils.metrics.MetricProvider in project infrautils by opendaylight.
the class PrometheusMetricProviderImplTest method testNewMeterWith1DynamicLabel.
@Test
public void testNewMeterWith1DynamicLabel() {
MetricProvider metricProvider = new PrometheusMetricProviderImpl(new CollectorRegistrySingleton());
Labeled<Meter> meterWithLabel = metricProvider.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_meter1").build(), "jobKey");
Meter meterA = meterWithLabel.label("ABC");
meterA.mark(3);
assertThat(meterA.get()).isEqualTo(3);
Meter meterB = meterWithLabel.label("DEF");
meterB.mark(1);
assertThat(meterB.get()).isEqualTo(1);
assertThat(meterA.get()).isEqualTo(3);
Meter againMeterA = meterWithLabel.label("ABC");
assertThat(againMeterA.get()).isEqualTo(3);
}
use of org.opendaylight.infrautils.metrics.MetricProvider in project genius by opendaylight.
the class JobCoordinatorTestModule method configure.
// The GuiceRule needs to include
// CloseableModule.class, Jsr250Module (but not the AutoCloseableModule)
// directly or via the org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module
// for this to work.
@Override
protected void configure() {
MetricProvider metricProvider = new TestMetricProviderImpl();
JobCoordinatorImpl jobCoordinatorImpl = new JobCoordinatorImpl(metricProvider);
bind(JobCoordinator.class).toInstance(jobCoordinatorImpl);
bind(JobCoordinatorMonitor.class).toInstance(jobCoordinatorImpl);
}
use of org.opendaylight.infrautils.metrics.MetricProvider in project infrautils by opendaylight.
the class PrometheusMetricProviderImplTest method testNewMeterWith1FixedLabel.
@Test
public void testNewMeterWith1FixedLabel() {
MetricProvider metricProvider = new PrometheusMetricProviderImpl(new CollectorRegistrySingleton());
Meter meter = metricProvider.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test").build(), "label1").label("value1");
meter.mark(123);
assertThat(meter.get()).isEqualTo(123L);
meter.close();
}
use of org.opendaylight.infrautils.metrics.MetricProvider in project infrautils by opendaylight.
the class PrometheusMetricProviderImplTest method testGetOverflownMeter.
@Test
public void testGetOverflownMeter() {
MetricProvider metricProvider = new PrometheusMetricProviderImpl(new CollectorRegistrySingleton());
Meter meter = metricProvider.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test").build());
meter.mark(Double.doubleToRawLongBits(Double.MAX_VALUE));
assertThat(meter.get()).isGreaterThan(1000000L);
}
use of org.opendaylight.infrautils.metrics.MetricProvider in project infrautils by opendaylight.
the class PrometheusMetricProviderImplTest method testNewMeter.
@Test
public void testNewMeter() {
MetricProvider metricProvider = new PrometheusMetricProviderImpl(new CollectorRegistrySingleton());
Meter meter = metricProvider.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test").build());
meter.mark(123);
assertThat(meter.get()).isEqualTo(123L);
meter.close();
}
Aggregations