use of org.springframework.boot.actuate.endpoint.PublicMetrics in project zipkin by openzipkin.
the class PrometheusMetricsAutoConfigurationTest method correctHttpResponse.
@Test
public void correctHttpResponse() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
assertThat(response.getHeaders().getContentType().toString(), equalTo("text/plain;version=0.0.4;charset=utf-8"));
}
use of org.springframework.boot.actuate.endpoint.PublicMetrics in project zipkin by openzipkin.
the class PrometheusMetricsAutoConfigurationTest method detectsCounters.
@Test
public void detectsCounters() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("counter_mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
String body = response.getBody();
assertThat(body, equalTo("#TYPE mem_free counter\n" + "#HELP mem_free mem_free\n" + "mem_free 1024.0\n"));
}
use of org.springframework.boot.actuate.endpoint.PublicMetrics in project zipkin by openzipkin.
the class PrometheusMetricsAutoConfigurationTest method detectsGauges.
@Test
public void detectsGauges() throws Exception {
PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("gauge_mem.free", 1024));
ResponseEntity<String> response = responseForMetrics(publicMetrics);
String body = response.getBody();
assertThat(body, equalTo("#TYPE mem_free gauge\n" + "#HELP mem_free mem_free\n" + "mem_free 1024.0\n"));
}
use of org.springframework.boot.actuate.endpoint.PublicMetrics in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method multipleDataSourcesWithPrimary.
@Test
public void multipleDataSourcesWithPrimary() {
load(MultipleDataSourcesWithPrimaryConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage", "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
use of org.springframework.boot.actuate.endpoint.PublicMetrics in project spring-boot by spring-projects.
the class PublicMetricsAutoConfigurationTests method multipleDataSources.
@Test
public void multipleDataSources() {
load(MultipleDataSourcesConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage", "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
// Hikari won't work unless a first connection has been retrieved
JdbcTemplate jdbcTemplate = new JdbcTemplate(this.context.getBean("hikariDS", DataSource.class));
jdbcTemplate.execute(new ConnectionCallback<Void>() {
@Override
public Void doInConnection(Connection connection) throws SQLException, DataAccessException {
return null;
}
});
Collection<Metric<?>> anotherMetrics = bean.metrics();
assertMetrics(anotherMetrics, "datasource.tomcat.active", "datasource.tomcat.usage", "datasource.hikariDS.active", "datasource.hikariDS.usage", "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
Aggregations