Search in sources :

Example 6 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project camel by apache.

the class MetricsComponentTest method testGetOrCreateMetricRegistryFoundInCamelRegistryByType.

@Test
public void testGetOrCreateMetricRegistryFoundInCamelRegistryByType() throws Exception {
    when(camelRegistry.lookupByNameAndType("name", MetricRegistry.class)).thenReturn(null);
    when(camelRegistry.findByType(MetricRegistry.class)).thenReturn(Collections.singleton(metricRegistry));
    MetricRegistry result = component.getOrCreateMetricRegistry(camelRegistry, "name");
    assertThat(result, is(metricRegistry));
    inOrder.verify(camelRegistry, times(1)).lookupByNameAndType("name", MetricRegistry.class);
    inOrder.verify(camelRegistry, times(1)).findByType(MetricRegistry.class);
    inOrder.verifyNoMoreInteractions();
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) Test(org.junit.Test)

Example 7 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project camel by apache.

the class MetricsComponentTest method testGetMetricRegistryFromCamelRegistry.

@Test
public void testGetMetricRegistryFromCamelRegistry() throws Exception {
    when(camelRegistry.lookupByNameAndType("name", MetricRegistry.class)).thenReturn(metricRegistry);
    MetricRegistry result = component.getMetricRegistryFromCamelRegistry(camelRegistry, "name");
    assertThat(result, is(metricRegistry));
    inOrder.verify(camelRegistry, times(1)).lookupByNameAndType("name", MetricRegistry.class);
    inOrder.verifyNoMoreInteractions();
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) Test(org.junit.Test)

Example 8 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project camel by apache.

the class MetricsComponentTest method testGetOrCreateMetricRegistryNotFoundInCamelRegistry.

@Test
public void testGetOrCreateMetricRegistryNotFoundInCamelRegistry() throws Exception {
    when(camelRegistry.lookupByNameAndType("name", MetricRegistry.class)).thenReturn(null);
    when(camelRegistry.findByType(MetricRegistry.class)).thenReturn(Collections.<MetricRegistry>emptySet());
    MetricRegistry result = component.getOrCreateMetricRegistry(camelRegistry, "name");
    assertThat(result, is(notNullValue()));
    assertThat(result, is(not(metricRegistry)));
    inOrder.verify(camelRegistry, times(1)).lookupByNameAndType("name", MetricRegistry.class);
    inOrder.verify(camelRegistry, times(1)).findByType(MetricRegistry.class);
    inOrder.verifyNoMoreInteractions();
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) Test(org.junit.Test)

Example 9 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project neo4j by neo4j.

the class CsvOutputTest method shouldHaveAbsoluteMetricsCsvPathBeAbsolute.

@Test
public void shouldHaveAbsoluteMetricsCsvPathBeAbsolute() throws Exception {
    // GIVEN
    File outputFPath = Files.createTempDirectory("output").toFile();
    Config config = config(MetricsSettings.csvEnabled.name(), "true", MetricsSettings.csvInterval.name(), "10ms", MetricsSettings.csvPath.name(), outputFPath.getAbsolutePath());
    life.add(new CsvOutput(config, new MetricRegistry(), NullLog.getInstance(), kernelContext));
    // WHEN
    life.start();
    // THEN
    waitForFileToAppear(outputFPath);
}
Also used : Config(org.neo4j.kernel.configuration.Config) MetricRegistry(com.codahale.metrics.MetricRegistry) File(java.io.File) Test(org.junit.Test)

Example 10 with MetricRegistry

use of com.codahale.metrics.MetricRegistry in project sharding-jdbc by dangdangdotcom.

the class MetricsContext method init.

/**
     * 初始化度量上下文持有者.
     * 
     * @param shardingProperties Sharding-JDBC的配置属性
     */
public static void init(final ShardingProperties shardingProperties) {
    HOLDER.remove();
    boolean metricsEnabled = shardingProperties.getValue(ShardingPropertiesConstant.METRICS_ENABLE);
    if (!metricsEnabled) {
        return;
    }
    long period = shardingProperties.getValue(ShardingPropertiesConstant.METRICS_MILLISECONDS_PERIOD);
    String loggerName = shardingProperties.getValue(ShardingPropertiesConstant.METRICS_LOGGER_NAME);
    MetricRegistry metricRegistry = new MetricRegistry();
    Slf4jReporter.forRegistry(metricRegistry).outputTo(LoggerFactory.getLogger(loggerName)).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG).build().start(period, TimeUnit.MILLISECONDS);
    HOLDER.set(metricRegistry);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)505 Test (org.junit.Test)177 Before (org.junit.Before)61 Test (org.junit.jupiter.api.Test)45 VerifiableProperties (com.github.ambry.config.VerifiableProperties)42 ArrayList (java.util.ArrayList)33 Counter (com.codahale.metrics.Counter)30 File (java.io.File)29 Properties (java.util.Properties)28 List (java.util.List)23 Metric (com.codahale.metrics.Metric)22 Map (java.util.Map)22 IOException (java.io.IOException)21 HashMap (java.util.HashMap)20 Size (com.github.joschi.jadconfig.util.Size)17 CountDownLatch (java.util.concurrent.CountDownLatch)17 TimeUnit (java.util.concurrent.TimeUnit)17 Timer (com.codahale.metrics.Timer)15 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)15 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)15