Search in sources :

Example 1 with MetricsSettings

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));
}
Also used : Counter(org.eclipse.microprofile.metrics.Counter) RegistryFactory(io.helidon.metrics.api.RegistryFactory) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) MetricsSettings(io.helidon.metrics.api.MetricsSettings) Test(org.junit.jupiter.api.Test)

Example 2 with MetricsSettings

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));
}
Also used : Counter(org.eclipse.microprofile.metrics.Counter) RegistryFilterSettings(io.helidon.metrics.api.RegistryFilterSettings) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) RegistrySettings(io.helidon.metrics.api.RegistrySettings) MetricsSettings(io.helidon.metrics.api.MetricsSettings) Test(org.junit.jupiter.api.Test)

Example 3 with MetricsSettings

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));
}
Also used : Counter(org.eclipse.microprofile.metrics.Counter) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) RegistrySettings(io.helidon.metrics.api.RegistrySettings) MetricsSettings(io.helidon.metrics.api.MetricsSettings) Test(org.junit.jupiter.api.Test)

Example 4 with MetricsSettings

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)));
}
Also used : MetricsSettings(io.helidon.metrics.api.MetricsSettings) Test(org.junit.jupiter.api.Test)

Example 5 with MetricsSettings

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);
}
Also used : RegistryFactory(io.helidon.metrics.api.RegistryFactory) MetricRegistry(org.eclipse.microprofile.metrics.MetricRegistry) MetricsSettings(io.helidon.metrics.api.MetricsSettings) Test(org.junit.jupiter.api.Test)

Aggregations

MetricsSettings (io.helidon.metrics.api.MetricsSettings)6 Test (org.junit.jupiter.api.Test)6 MetricRegistry (org.eclipse.microprofile.metrics.MetricRegistry)5 Counter (org.eclipse.microprofile.metrics.Counter)4 RegistryFactory (io.helidon.metrics.api.RegistryFactory)3 RegistrySettings (io.helidon.metrics.api.RegistrySettings)2 RegistryFilterSettings (io.helidon.metrics.api.RegistryFilterSettings)1