use of org.opendaylight.infrautils.metrics.Meter in project infrautils by opendaylight.
the class MetricProviderTest method testMeter.
@Test
public void testMeter() {
Meter meter1 = metrics.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_meter1").build());
meter1.mark();
meter1.mark(2);
assertThat(meter1.get()).isEqualTo(3);
}
use of org.opendaylight.infrautils.metrics.Meter 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.Meter in project infrautils by opendaylight.
the class MetricProviderTest method testMeterWith2Labels.
@Test
public void testMeterWith2Labels() {
Labeled<Labeled<Meter>> meterWithTwoLabels = metrics.newMeter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_meter1").build(), "port", "mac");
Meter meterA = meterWithTwoLabels.label(/* port */
"456").label(/* MAC */
"1A:0B:F2:25:1C:68");
meterA.mark(3);
assertThat(meterA.get()).isEqualTo(3);
Meter meterB = meterWithTwoLabels.label(/* port */
"789").label(/* MAC */
"1A:0B:F2:25:1C:68");
meterB.mark(1);
assertThat(meterB.get()).isEqualTo(1);
assertThat(meterA.get()).isEqualTo(3);
Meter againMeterA = meterWithTwoLabels.label(/* port */
"456").label(/* MAC */
"1A:0B:F2:25:1C:68");
assertThat(againMeterA.get()).isEqualTo(3);
}
use of org.opendaylight.infrautils.metrics.Meter in project infrautils by opendaylight.
the class MetricProviderTest method testUseClosedMeter.
@Test
public void testUseClosedMeter() {
Meter meter1 = metrics.newMeter(this, "test.meter1");
meter1.close();
assertThrows(IllegalStateException.class, meter1::mark);
// Closing an already closed metric throws an IllegalStateException
assertThrows(IllegalStateException.class, meter1::close);
}
use of org.opendaylight.infrautils.metrics.Meter in project infrautils by opendaylight.
the class MetricProviderTest method testCloseMeterAndCreateNewOneWithSameID.
@Test
public void testCloseMeterAndCreateNewOneWithSameID() {
Meter meter = metrics.newMeter(this, "test.meter");
meter.close();
Meter meterAgain = metrics.newMeter(this, "test.meter");
meterAgain.mark();
}
Aggregations