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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations