Search in sources :

Example 1 with MetricProvider

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);
}
Also used : MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) PrometheusMetricProviderImpl(org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl) Meter(org.opendaylight.infrautils.metrics.Meter) CollectorRegistrySingleton(org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton) Test(org.junit.Test)

Example 2 with MetricProvider

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);
}
Also used : JobCoordinatorMonitor(org.opendaylight.infrautils.jobcoordinator.JobCoordinatorMonitor) JobCoordinatorImpl(org.opendaylight.infrautils.jobcoordinator.internal.JobCoordinatorImpl) MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) TestMetricProviderImpl(org.opendaylight.infrautils.metrics.testimpl.TestMetricProviderImpl) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator)

Example 3 with MetricProvider

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();
}
Also used : MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) PrometheusMetricProviderImpl(org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl) Meter(org.opendaylight.infrautils.metrics.Meter) CollectorRegistrySingleton(org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton) Test(org.junit.Test)

Example 4 with MetricProvider

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);
}
Also used : MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) PrometheusMetricProviderImpl(org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl) Meter(org.opendaylight.infrautils.metrics.Meter) CollectorRegistrySingleton(org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton) Test(org.junit.Test)

Example 5 with MetricProvider

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();
}
Also used : MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) PrometheusMetricProviderImpl(org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl) Meter(org.opendaylight.infrautils.metrics.Meter) CollectorRegistrySingleton(org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton) Test(org.junit.Test)

Aggregations

MetricProvider (org.opendaylight.infrautils.metrics.MetricProvider)5 Test (org.junit.Test)4 Meter (org.opendaylight.infrautils.metrics.Meter)4 CollectorRegistrySingleton (org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton)4 PrometheusMetricProviderImpl (org.opendaylight.infrautils.metrics.prometheus.impl.PrometheusMetricProviderImpl)4 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)1 JobCoordinatorMonitor (org.opendaylight.infrautils.jobcoordinator.JobCoordinatorMonitor)1 JobCoordinatorImpl (org.opendaylight.infrautils.jobcoordinator.internal.JobCoordinatorImpl)1 TestMetricProviderImpl (org.opendaylight.infrautils.metrics.testimpl.TestMetricProviderImpl)1