use of org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton 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.prometheus.impl.CollectorRegistrySingleton in project infrautils by opendaylight.
the class MetricsPrometheusExampleMain method main.
public static void main(String[] args) throws IOException {
// see also OsgiWebInitializer
CollectorRegistry collectorRegistry = new CollectorRegistrySingleton();
PrometheusMetricProviderImpl metricProvider = new PrometheusMetricProviderImpl(collectorRegistry);
MetricsExample metricsExample = new MetricsExample(metricProvider);
metricsExample.init();
HTTPServer server = new HTTPServer(new InetSocketAddress("localhost", 1234), collectorRegistry);
System.in.read();
server.stop();
metricsExample.close();
metricProvider.close();
}
use of org.opendaylight.infrautils.metrics.prometheus.impl.CollectorRegistrySingleton 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.prometheus.impl.CollectorRegistrySingleton 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.prometheus.impl.CollectorRegistrySingleton 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