use of org.opendaylight.infrautils.metrics.Counter in project infrautils by opendaylight.
the class MetricProviderTest method testCounterWith2Labels.
@Test
public void testCounterWith2Labels() {
Labeled<Labeled<Counter>> counterWithTwoLabels = metrics.newCounter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_counter1").build(), "port", "mac");
Counter counterA = counterWithTwoLabels.label(/* port */
"456").label(/* MAC */
"1A:0B:F2:25:1C:68");
counterA.increment(3);
assertThat(counterA.get()).isEqualTo(3);
Counter counterB = counterWithTwoLabels.label(/* port */
"789").label(/* MAC */
"1A:0B:F2:25:1C:68");
counterB.increment(1);
assertThat(counterB.get()).isEqualTo(1);
assertThat(counterA.get()).isEqualTo(3);
Counter againCounterA = counterWithTwoLabels.label(/* port */
"456").label(/* MAC */
"1A:0B:F2:25:1C:68");
assertThat(againCounterA.get()).isEqualTo(3);
}
use of org.opendaylight.infrautils.metrics.Counter in project infrautils by opendaylight.
the class MetricProviderTest method testSameCounterUpdateOperationsWithLabels.
@Test
public void testSameCounterUpdateOperationsWithLabels() {
Labeled<Labeled<Counter>> counterWithTwoLabels = metrics.newCounter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_counter_upd_opers").build(), "l1", "l2");
Counter counterA = counterWithTwoLabels.label("l1value").label("l2value");
counterA.increment(51);
assertThat(counterA.get()).isEqualTo(51);
counterA.decrement();
assertThat(counterA.get()).isEqualTo(50);
Labeled<Labeled<Counter>> sameCounterWithTwoLabels = metrics.newCounter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_counter_upd_opers").build(), "l1", "l2");
Counter sameCounterA = sameCounterWithTwoLabels.label("l1value").label("l2value");
assertThat(sameCounterA).isEqualTo(counterA);
assertThat(sameCounterA.get()).isEqualTo(50);
sameCounterA.increment(5);
assertThat(sameCounterA.get()).isEqualTo(55);
sameCounterA.decrement(10);
assertThat(sameCounterA.get()).isEqualTo(45);
sameCounterA.close();
}
use of org.opendaylight.infrautils.metrics.Counter in project infrautils by opendaylight.
the class MetricProviderTest method testCounterOperationsWithLabels.
@Test
public void testCounterOperationsWithLabels() {
Labeled<Labeled<Counter>> counterWithTwoLabels = metrics.newCounter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_counter_opers").build(), "l1", "l2");
Counter counterA = counterWithTwoLabels.label("l1value").label("l2value");
counterA.increment();
counterA.increment();
assertThat(counterA.get()).isEqualTo(2);
counterA.decrement();
assertThat(counterA.get()).isEqualTo(1);
counterA.increment(5);
assertThat(counterA.get()).isEqualTo(6);
counterA.decrement(2);
assertThat(counterA.get()).isEqualTo(4);
counterA.close();
}
use of org.opendaylight.infrautils.metrics.Counter in project infrautils by opendaylight.
the class MetricsIntegrationTest method testMetrics.
@Test
public void testMetrics() {
// The main point here is just to make sure that Dropwizard Codahale Metrics really works at runtime under OSGi
Counter counter1 = metricProvider.newCounter(this, "odl.infrautils.metrics.IntegrationTest.counter1");
counter1.increment();
}
Aggregations