Adapt to latest change in Micrometer 1.1

This commit is contained in:
Stephane Nicoll 2018-10-05 23:42:16 +02:00
parent 12cb478b0d
commit 35752a54d2
6 changed files with 14 additions and 14 deletions

View File

@ -29,9 +29,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public class ElasticProperties extends StepRegistryProperties { public class ElasticProperties extends StepRegistryProperties {
/** /**
* Hosts to export metrics to. * Host to export metrics to.
*/ */
private String[] hosts = new String[] { "http://localhost:9200" }; private String host = "http://localhost:9200";
/** /**
* Index to export metrics to. * Index to export metrics to.
@ -64,12 +64,12 @@ public class ElasticProperties extends StepRegistryProperties {
*/ */
private String password = ""; private String password = "";
public String[] getHosts() { public String getHost() {
return this.hosts; return this.host;
} }
public void setHosts(String[] hosts) { public void setHost(String host) {
this.hosts = hosts; this.host = host;
} }
public String getIndex() { public String getIndex() {

View File

@ -33,8 +33,8 @@ class ElasticPropertiesConfigAdapter extends
} }
@Override @Override
public String[] hosts() { public String host() {
return get(ElasticProperties::getHosts, ElasticConfig.super::hosts); return get(ElasticProperties::getHost, ElasticConfig.super::host);
} }
@Override @Override

View File

@ -30,9 +30,9 @@ public class ElasticPropertiesConfigAdapterTests {
@Test @Test
public void whenPropertiesHostsIsSetAdapterHostsReturnsIt() { public void whenPropertiesHostsIsSetAdapterHostsReturnsIt() {
ElasticProperties properties = new ElasticProperties(); ElasticProperties properties = new ElasticProperties();
properties.setHosts(new String[] { "https://elastic.example.com" }); properties.setHost("https://elastic.example.com");
assertThat(new ElasticPropertiesConfigAdapter(properties).hosts()) assertThat(new ElasticPropertiesConfigAdapter(properties).host())
.isEqualTo(new String[] { "https://elastic.example.com" }); .isEqualTo("https://elastic.example.com");
} }
@Test @Test

View File

@ -34,7 +34,7 @@ public class ElasticPropertiesTests extends StepRegistryPropertiesTests {
ElasticProperties properties = new ElasticProperties(); ElasticProperties properties = new ElasticProperties();
ElasticConfig config = ElasticConfig.DEFAULT; ElasticConfig config = ElasticConfig.DEFAULT;
assertStepRegistryDefaultValues(properties, config); assertStepRegistryDefaultValues(properties, config);
assertThat(properties.getHosts()).isEqualTo(config.hosts()); assertThat(properties.getHost()).isEqualTo(config.host());
assertThat(properties.getIndex()).isEqualTo(config.index()); assertThat(properties.getIndex()).isEqualTo(config.index());
assertThat(properties.getIndexDateFormat()).isEqualTo(config.indexDateFormat()); assertThat(properties.getIndexDateFormat()).isEqualTo(config.indexDateFormat());
assertThat(properties.getPassword()).isEqualTo(config.password()); assertThat(properties.getPassword()).isEqualTo(config.password());

View File

@ -1422,7 +1422,7 @@ content into your application. Rather, pick only the properties that you need.
management.metrics.export.elastic.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. management.metrics.export.elastic.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made.
management.metrics.export.elastic.connect-timeout=1s # Connection timeout for requests to this backend. management.metrics.export.elastic.connect-timeout=1s # Connection timeout for requests to this backend.
management.metrics.export.elastic.enabled=true # Whether exporting of metrics to this backend is enabled. management.metrics.export.elastic.enabled=true # Whether exporting of metrics to this backend is enabled.
management.metrics.export.elastic.hosts=http://localhost:9200 # Hosts to export metrics to. management.metrics.export.elastic.host=http://localhost:9200 # Host to export metrics to.
management.metrics.export.elastic.index=metrics # Index to export metrics to. management.metrics.export.elastic.index=metrics # Index to export metrics to.
management.metrics.export.elastic.index-date-format=yyyy-MM # Index date format used for rolling indices. Appended to the index name, preceded by a '-'. management.metrics.export.elastic.index-date-format=yyyy-MM # Index date format used for rolling indices. Appended to the index name, preceded by a '-'.
management.metrics.export.elastic.num-threads=2 # Number of threads to use with the metrics publishing scheduler. management.metrics.export.elastic.num-threads=2 # Number of threads to use with the metrics publishing scheduler.

View File

@ -1490,7 +1490,7 @@ using the following property:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.metrics.export.elastic.hosts=http://elastic.example.com:8086 management.metrics.export.elastic.host=http://elastic.example.com:8086
---- ----