use of io.helidon.metrics.api.MetricsSettings in project helidon by oracle.
the class TestDisableEntireRegistry method testVendorRegistryEnabled.
@Test
void testVendorRegistryEnabled() {
MetricsSettings metricsSettings = MetricsSettings.create(metricsConfig);
assertThat("Vendor registry is enabled", metricsSettings.registrySettings(MetricRegistry.Type.VENDOR).isEnabled(), is(true));
io.helidon.metrics.api.RegistryFactory registryFactory = RegistryFactory.create(metricsSettings);
MetricRegistry vendorRegistry = registryFactory.getRegistry(MetricRegistry.Type.VENDOR);
Counter vendorCounter = vendorRegistry.counter("shouldUpdate");
vendorCounter.inc();
assertThat("Counter in enabled vendor registry", vendorCounter.getCount(), is(1L));
}
use of io.helidon.metrics.api.MetricsSettings in project helidon by oracle.
the class TestDisabled method testDisabledMetric.
@Test
void testDisabledMetric() {
RegistryFilterSettings.Builder filterBuilder = RegistryFilterSettings.builder().exclude("dormant.*");
RegistrySettings settings = RegistrySettings.builder().filterSettings(filterBuilder).build();
MetricsSettings metricsSettings = MetricsSettings.builder().registrySettings(MetricRegistry.Type.APPLICATION, settings).build();
io.helidon.metrics.api.RegistryFactory registryFactory = io.helidon.metrics.api.RegistryFactory.create(metricsSettings);
MetricRegistry registry = registryFactory.getRegistry(MetricRegistry.Type.APPLICATION);
Counter activeCounter = registry.counter("activeCounter");
activeCounter.inc();
assertThat("Active counter after inc", activeCounter.getCount(), is(1L));
Counter dormantCounter = registry.counter("dormantCounter");
dormantCounter.inc();
assertThat("Dormant counter after inc", dormantCounter.getCount(), is(0L));
}
use of io.helidon.metrics.api.MetricsSettings in project helidon by oracle.
the class TestDisabled method testDisabledRegistry.
@Test
void testDisabledRegistry() {
RegistrySettings settings = RegistrySettings.builder().enabled(false).build();
MetricsSettings metricsSettings = MetricsSettings.builder().registrySettings(MetricRegistry.Type.APPLICATION, settings).build();
io.helidon.metrics.api.RegistryFactory registryFactory = io.helidon.metrics.api.RegistryFactory.create(metricsSettings);
MetricRegistry registry = registryFactory.getRegistry(MetricRegistry.Type.APPLICATION);
Counter activeCounter = registry.counter("activeCounter");
long original = activeCounter.getCount();
activeCounter.inc();
assertThat("Difference in active counter in disabled registry after inc", activeCounter.getCount() - original, is(0L));
}
use of io.helidon.metrics.api.MetricsSettings in project helidon by oracle.
the class TestDisabledEntirely method testDisabledCompletely.
@Test
void testDisabledCompletely() {
MetricsSettings metricsSettings = MetricsSettings.builder().enabled(false).build();
io.helidon.metrics.api.RegistryFactory registryFactory = io.helidon.metrics.api.RegistryFactory.getInstance(metricsSettings);
assertThat("Disabled RegistryFactory impl class", registryFactory, not(instanceOf(io.helidon.metrics.RegistryFactory.class)));
}
use of io.helidon.metrics.api.MetricsSettings in project helidon by oracle.
the class TestSettingsAndConfig method checkRegistryWithDisabledSettings.
@Test
void checkRegistryWithDisabledSettings() {
MetricsSettings metricsSettings = MetricsSettings.builder().enabled(false).build();
RegistryFactory registryFactory = RegistryFactory.create(metricsSettings);
MetricRegistry metricRegistry = registryFactory.getRegistry(MetricRegistry.Type.APPLICATION);
checkCounterValueAfterInc(metricRegistry, "counter-disabled-via-settings", 0L);
}
Aggregations