use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method autoDataSource.
@Test
public void autoDataSource() {
load(DataSourceAutoConfiguration.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method customPrefix.
@Test
public void customPrefix() {
load(MultipleDataSourcesWithPrimaryConfig.class, CustomDataSourcePublicMetrics.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active", "ds.second.usage");
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class DefaultCounterServiceSpeedTests method counters.
@Theory
public void counters(String input) throws Exception {
watch.start("counters" + count++);
ExecutorService pool = Executors.newFixedThreadPool(threadCount);
Runnable task = new Runnable() {
@Override
public void run() {
for (int i = 0; i < number; i++) {
String name = sample[i % sample.length];
DefaultCounterServiceSpeedTests.this.counterService.increment(name);
}
}
};
Collection<Future<?>> futures = new HashSet<>();
for (int i = 0; i < threadCount; i++) {
futures.add(pool.submit(task));
}
for (Future<?> future : futures) {
future.get();
}
watch.stop();
double rate = number / watch.getLastTaskTimeMillis() * 1000;
System.err.println("Counters rate(" + count + ")=" + rate + ", " + watch);
watch.start("read" + count);
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> metric) {
err.println(metric);
}
});
final LongAdder total = new LongAdder();
this.reader.findAll().forEach(new Consumer<Metric<?>>() {
@Override
public void accept(Metric<?> value) {
total.add(value.getValue().intValue());
}
});
watch.stop();
System.err.println("Read(" + count + ")=" + watch.getLastTaskTimeMillis() + "ms");
assertThat(total.longValue()).isEqualTo(number * threadCount);
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class MetricReaderPublicMetricsTests method exposesMetrics.
@Test
public void exposesMetrics() {
List<Metric<?>> metrics = new ArrayList<>();
metrics.add(mock(Metric.class));
metrics.add(mock(Metric.class));
MetricReader reader = mock(MetricReader.class);
given(reader.findAll()).willReturn(metrics);
MetricReaderPublicMetrics publicMetrics = new MetricReaderPublicMetrics(reader);
assertThat(publicMetrics.metrics()).isEqualTo(metrics);
}
use of org.springframework.boot.actuate.metrics.Metric in project spring-boot by spring-projects.
the class TomcatPublicMetricsTests method tomcatMetrics.
@Test
public void tomcatMetrics() throws Exception {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(Config.class);
try {
TomcatPublicMetrics tomcatMetrics = context.getBean(TomcatPublicMetrics.class);
Iterator<Metric<?>> metrics = tomcatMetrics.metrics().iterator();
assertThat(metrics.next().getName()).isEqualTo("httpsessions.max");
assertThat(metrics.next().getName()).isEqualTo("httpsessions.active");
assertThat(metrics.hasNext()).isFalse();
} finally {
context.close();
}
}
Aggregations