diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java index 73a693a644..558746098e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java @@ -24,8 +24,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; /** * {@link ConfigurationProperties} for configuring Atlas metrics export. * - * @since 2.0.0 * @author Jon Schneider + * @author Stephane Nicoll + * @since 2.0.0 */ @ConfigurationProperties(prefix = "management.metrics.export.atlas") public class AtlasProperties extends StepRegistryProperties { @@ -33,38 +34,38 @@ public class AtlasProperties extends StepRegistryProperties { /** * URI of the Atlas server. */ - private String uri; + private String uri = "http://localhost:7101/api/v1/publish"; /** * Time to live for meters that do not have any activity. After this period the meter * will be considered expired and will not get reported. */ - private Duration meterTimeToLive; + private Duration meterTimeToLive = Duration.ofMinutes(15); /** - * Enable streaming to Atlas LWC. + * Whether to enable streaming to Atlas LWC. */ - private Boolean lwcEnabled; + private boolean lwcEnabled; /** * Frequency for refreshing config settings from the LWC service. */ - private Duration configRefreshFrequency; + private Duration configRefreshFrequency = Duration.ofSeconds(10); /** * Time to live for subscriptions from the LWC service. */ - private Duration configTimeToLive; + private Duration configTimeToLive = Duration.ofSeconds(150); /** * URI for the Atlas LWC endpoint to retrieve current subscriptions. */ - private String configUri; + private String configUri = "http://localhost:7101/lwc/api/v1/expressions/local-dev"; /** * URI for the Atlas LWC endpoint to evaluate the data for a subscription. */ - private String evalUri; + private String evalUri = "http://localhost:7101/lwc/api/v1/evaluate"; public String getUri() { return this.uri; @@ -82,11 +83,11 @@ public class AtlasProperties extends StepRegistryProperties { this.meterTimeToLive = meterTimeToLive; } - public Boolean getLwcEnabled() { + public boolean isLwcEnabled() { return this.lwcEnabled; } - public void setLwcEnabled(Boolean lwcEnabled) { + public void setLwcEnabled(boolean lwcEnabled) { this.lwcEnabled = lwcEnabled; } @@ -121,4 +122,5 @@ public class AtlasProperties extends StepRegistryProperties { public void setEvalUri(String evalUri) { this.evalUri = evalUri; } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java index 418479fd6a..8fb5632b86 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java @@ -47,7 +47,7 @@ class AtlasPropertiesConfigAdapter extends PropertiesConfigAdapter null; + assertThat(properties.getStep()).isEqualTo(config.step()); + assertThat(properties.isEnabled()).isEqualTo(config.enabled()); + assertThat(properties.getConnectTimeout()).isEqualTo(config.connectTimeout()); + assertThat(properties.getReadTimeout()).isEqualTo(config.readTimeout()); + assertThat(properties.getNumThreads()).isEqualTo(config.numThreads()); + assertThat(properties.getBatchSize()).isEqualTo(config.batchSize()); + assertThat(properties.getUri()).isEqualTo(config.uri()); + assertThat(properties.getMeterTimeToLive()).isEqualTo(config.meterTTL()); + assertThat(properties.isLwcEnabled()).isEqualTo(config.lwcEnabled()); + assertThat(properties.getConfigRefreshFrequency()) + .isEqualTo(config.configRefreshFrequency()); + assertThat(properties.getConfigTimeToLive()).isEqualTo(config.configTTL()); + assertThat(properties.getConfigUri()).isEqualTo(config.configUri()); + assertThat(properties.getEvalUri()).isEqualTo(config.evalUri()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogPropertiesTests.java new file mode 100644 index 0000000000..4dea6bc715 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogPropertiesTests.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog; + +import io.micrometer.datadog.DatadogConfig; + +import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link DatadogProperties}. + * + * @author Stephane Nicoll + */ +public class DatadogPropertiesTests extends StepRegistryPropertiesTests { + + @Override + public void defaultValuesAreConsistent() { + DatadogProperties properties = new DatadogProperties(); + DatadogConfig config = DatadogConfig.DEFAULT; + assertStepRegistryDefaultValues(properties, config); + assertThat(properties.isDescriptions()).isEqualTo(config.descriptions()); + assertThat(properties.getHostTag()).isEqualTo(config.hostTag()); + assertThat(properties.getUri()).isEqualTo(config.uri()); + } +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesTests.java new file mode 100644 index 0000000000..cd4218814f --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesTests.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia; + +import io.micrometer.ganglia.GangliaConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link GangliaProperties}. + * + * @author Stephane Nicoll + */ +public class GangliaPropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + GangliaProperties properties = new GangliaProperties(); + GangliaConfig config = GangliaConfig.DEFAULT; + assertThat(properties.isEnabled()).isEqualTo(config.enabled()); + assertThat(properties.getStep()).isEqualTo(config.step()); + assertThat(properties.getRateUnits()).isEqualTo(config.rateUnits()); + assertThat(properties.getDurationUnits()).isEqualTo(config.durationUnits()); + assertThat(properties.getProtocolVersion()).isEqualTo(config.protocolVersion()); + assertThat(properties.getAddressingMode()).isEqualTo(config.addressingMode()); + assertThat(properties.getTimeToLive()).isEqualTo(config.ttl()); + assertThat(properties.getHost()).isEqualTo(config.host()); + assertThat(properties.getPort()).isEqualTo(config.port()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphitePropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphitePropertiesTests.java new file mode 100644 index 0000000000..c11bcd5d6a --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphitePropertiesTests.java @@ -0,0 +1,45 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite; + +import io.micrometer.graphite.GraphiteConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link GraphiteProperties}. + * + * @author Stephane Nicoll + */ +public class GraphitePropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + GraphiteProperties properties = new GraphiteProperties(); + GraphiteConfig config = GraphiteConfig.DEFAULT; + assertThat(properties.isEnabled()).isEqualTo(config.enabled()); + assertThat(properties.getStep()).isEqualTo(config.step()); + assertThat(properties.getRateUnits()).isEqualTo(config.rateUnits()); + assertThat(properties.getDurationUnits()).isEqualTo(config.durationUnits()); + assertThat(properties.getHost()).isEqualTo(config.host()); + assertThat(properties.getPort()).isEqualTo(config.port()); + assertThat(properties.getProtocol()).isEqualTo(config.protocol()); + assertThat(properties.getTagsAsPrefix()).isEqualTo(config.tagsAsPrefix()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesTests.java new file mode 100644 index 0000000000..4d62674b11 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesTests.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.influx; + +import io.micrometer.influx.InfluxConfig; + +import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link InfluxProperties}. + * + * @author Stephane Nicoll + */ +public class InfluxPropertiesTests extends StepRegistryPropertiesTests { + + @Override + public void defaultValuesAreConsistent() { + InfluxProperties properties = new InfluxProperties(); + InfluxConfig config = InfluxConfig.DEFAULT; + assertStepRegistryDefaultValues(properties, config); + assertThat(properties.getDb()).isEqualTo(config.db()); + assertThat(properties.getConsistency()).isEqualTo(config.consistency()); + assertThat(properties.getUserName()).isEqualTo(config.userName()); + assertThat(properties.getPassword()).isEqualTo(config.password()); + assertThat(properties.getRetentionPolicy()).isEqualTo(config.retentionPolicy()); + assertThat(properties.getUri()).isEqualTo(config.uri()); + assertThat(properties.isCompressed()).isEqualTo(config.compressed()); + assertThat(properties.isAutoCreateDb()).isEqualTo(config.autoCreateDb()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxPropertiesTests.java new file mode 100644 index 0000000000..0fc9a32e27 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxPropertiesTests.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.jmx; + +import io.micrometer.jmx.JmxConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link JmxProperties}. + * + * @author Stephane Nicoll + */ +public class JmxPropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + JmxProperties properties = new JmxProperties(); + JmxConfig config = JmxConfig.DEFAULT; + assertThat(properties.getStep()).isEqualTo(config.step()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicPropertiesTests.java new file mode 100644 index 0000000000..a8846ff628 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicPropertiesTests.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.newrelic; + +import io.micrometer.newrelic.NewRelicConfig; + +import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link NewRelicProperties}. + * + * @author Stephane Nicoll + */ +public class NewRelicPropertiesTests extends StepRegistryPropertiesTests { + + @Override + public void defaultValuesAreConsistent() { + NewRelicProperties properties = new NewRelicProperties(); + NewRelicConfig config = NewRelicConfig.DEFAULT; + assertStepRegistryDefaultValues(properties, config); + // apiKey and account are mandatory + assertThat(properties.getUri()).isEqualTo(config.uri()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesTests.java new file mode 100644 index 0000000000..b8db882803 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesTests.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus; + +import io.micrometer.prometheus.PrometheusConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link PrometheusProperties}. + * + * @author Stephane Nicoll + */ +public class PrometheusPropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + PrometheusProperties properties = new PrometheusProperties(); + PrometheusConfig config = PrometheusConfig.DEFAULT; + assertThat(properties.isDescriptions()).isEqualTo(config.descriptions()); + assertThat(properties.getStep()).isEqualTo(config.step()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesTests.java new file mode 100644 index 0000000000..3d7144d88b --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesTests.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.properties; + +import io.micrometer.core.instrument.step.StepRegistryConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Base tests for {@link StepRegistryProperties} implementation. + * + * @author Stephane Nicoll + */ +public abstract class StepRegistryPropertiesTests { + + protected void assertStepRegistryDefaultValues(StepRegistryProperties properties, + StepRegistryConfig config) { + assertThat(properties.getStep()).isEqualTo(config.step()); + assertThat(properties.isEnabled()).isEqualTo(config.enabled()); + assertThat(properties.getConnectTimeout()).isEqualTo(config.connectTimeout()); + assertThat(properties.getReadTimeout()).isEqualTo(config.readTimeout()); + assertThat(properties.getNumThreads()).isEqualTo(config.numThreads()); + assertThat(properties.getBatchSize()).isEqualTo(config.batchSize()); + } + + @Test + public abstract void defaultValuesAreConsistent(); + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesTests.java new file mode 100644 index 0000000000..517692c818 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesTests.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx; + +import io.micrometer.signalfx.SignalFxConfig; + +import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link SignalFxProperties}. + * + * @author Stephane Nicoll + */ +public class SignalFxPropertiesTests extends StepRegistryPropertiesTests { + + @Override + public void defaultValuesAreConsistent() { + SignalFxProperties properties = new SignalFxProperties(); + SignalFxConfig config = SignalFxConfig.DEFAULT; + assertStepRegistryDefaultValues(properties, config); + // access token is mandatory + assertThat(properties.getUri()).isEqualTo(config.uri()); + // source has no static default value + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesTests.java new file mode 100644 index 0000000000..36f3a1e250 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesTests.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.simple; + +import io.micrometer.core.instrument.simple.SimpleConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * + * @author Stephane Nicoll + */ +public class SimplePropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + SimpleProperties properties = new SimpleProperties(); + SimpleConfig config = SimpleConfig.DEFAULT; + assertThat(properties.getStep()).isEqualTo(config.step()); + assertThat(properties.getMode()).isEqualTo(config.mode()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesTests.java new file mode 100644 index 0000000000..69fea27db5 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesTests.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.statsd; + +import io.micrometer.statsd.StatsdConfig; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link StatsdProperties}. + * + * @author Stephane Nicoll + */ +public class StatsdPropertiesTests { + + @Test + public void defaultValuesAreConsistent() { + StatsdProperties properties = new StatsdProperties(); + StatsdConfig config = StatsdConfig.DEFAULT; + assertThat(properties.isEnabled()).isEqualTo(config.enabled()); + assertThat(properties.getFlavor()).isEqualTo(config.flavor()); + assertThat(properties.getHost()).isEqualTo(config.host()); + assertThat(properties.getPort()).isEqualTo(config.port()); + assertThat(properties.getMaxPacketLength()).isEqualTo(config.maxPacketLength()); + assertThat(properties.getPollingFrequency()).isEqualTo(config.pollingFrequency()); + assertThat(properties.getQueueSize()).isEqualTo(config.queueSize()); + assertThat(properties.isPublishUnchangedMeters()) + .isEqualTo(config.publishUnchangedMeters()); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java new file mode 100644 index 0000000000..0ee1c276ec --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront; + +import io.micrometer.wavefront.WavefrontConfig; + +import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link WavefrontProperties}. + * + * @author Stephane Nicoll + */ +public class WavefrontPropertiesTests extends StepRegistryPropertiesTests { + + @Override + public void defaultValuesAreConsistent() { + WavefrontProperties properties = new WavefrontProperties(); + WavefrontConfig config = WavefrontConfig.DEFAULT_DIRECT; + assertStepRegistryDefaultValues(properties, config); + assertThat(properties.getUri().toString()).isEqualTo(config.uri()); + // source has no static default value + assertThat(properties.getApiToken()).isEqualTo(config.apiToken()); + assertThat(properties.getGlobalPrefix()).isEqualTo(config.globalPrefix()); + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 1dc142a9e9..1789ee17ad 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1305,98 +1305,105 @@ content into your application. Rather, pick only the properties that you need. management.metrics.distribution.percentiles.*= # Specific computed non-aggregable percentiles to ship to the backend for meter IDs starting-with the specified name. management.metrics.distribution.sla.*= Specific SLA boundaries for meter IDs starting-with the specified name. The longest match wins, the key `all` can also be used to configure all meters. management.metrics.enable.*= # Whether meter IDs starting-with the specified name should be enabled. The longest match wins, the key `all` can also be used to configure all meters. - management.metrics.export.atlas.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. - management.metrics.export.atlas.config-refresh-frequency= # Frequency for refreshing config settings from the LWC service. - management.metrics.export.atlas.config-time-to-live= # Time to live for subscriptions from the LWC service. - management.metrics.export.atlas.config-uri= # URI for the Atlas LWC endpoint to retrieve current subscriptions. - management.metrics.export.atlas.connect-timeout= # Connection timeout for requests to the backend. - management.metrics.export.atlas.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.atlas.eval-uri= # URI for the Atlas LWC endpoint to evaluate the data for a subscription. - management.metrics.export.atlas.lwc-enabled= # Enable streaming to Atlas LWC. - management.metrics.export.atlas.meter-time-to-live= # Time to live for meters that do not have any activity. After this period the meter will be considered expired and will not get reported. - management.metrics.export.atlas.num-threads= # Number of threads to use with the metrics publishing scheduler. - management.metrics.export.atlas.read-timeout= # Read timeout for requests to the backend. + management.metrics.export.atlas.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.atlas.config-refresh-frequency=10s # Frequency for refreshing config settings from the LWC service. + management.metrics.export.atlas.config-time-to-live=150s # Time to live for subscriptions from the LWC service. + management.metrics.export.atlas.config-uri=http://localhost:7101/lwc/api/v1/expressions/local-dev # URI for the Atlas LWC endpoint to retrieve current subscriptions. + management.metrics.export.atlas.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.atlas.enabled=true # Whether exporting of metrics to this backend is enabled. + management.metrics.export.atlas.eval-uri=http://localhost:7101/lwc/api/v1/evaluate # URI for the Atlas LWC endpoint to evaluate the data for a subscription. + management.metrics.export.atlas.lwc-enabled=false # Whether to enable streaming to Atlas LWC. + management.metrics.export.atlas.meter-time-to-live=15m # Time to live for meters that do not have any activity. After this period the meter will be considered expired and will not get reported. + management.metrics.export.atlas.num-threads=2 # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.atlas.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.atlas.step=1m # Step size (i.e. reporting frequency) to use. - management.metrics.export.atlas.uri= # URI of the Atlas server. + management.metrics.export.atlas.uri=http://localhost:7101/api/v1/publish # URI of the Atlas server. management.metrics.export.datadog.api-key= # Datadog API key. - management.metrics.export.datadog.application-key= # Datadog application key. - management.metrics.export.datadog.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. - management.metrics.export.datadog.connect-timeout= # Connection timeout for requests to the backend. - management.metrics.export.datadog.descriptions= # Whether to publish descriptions metadata to Datadog. Turn this off to minimize the amount of metadata sent. + management.metrics.export.datadog.application-key= # Datadog application key. Not strictly required, but improves the Datadog experience by sending meter descriptions, types, and base units to Datadog. + management.metrics.export.datadog.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.datadog.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.datadog.descriptions=true # Whether to publish descriptions metadata to Datadog. Turn this off to minimize the amount of metadata sent. management.metrics.export.datadog.enabled=true # Whether exporting of metrics to this backend is enabled. - management.metrics.export.datadog.host-tag= # Tag that will be mapped to "host" when shipping metrics to Datadog. Can be omitted if host should be omitted on publishing. - management.metrics.export.datadog.num-threads= # Number of threads to use with the metrics publishing scheduler. - management.metrics.export.datadog.read-timeout= # Read timeout for requests to the backend. + management.metrics.export.datadog.host-tag=instance # Tag that will be mapped to "host" when shipping metrics to Datadog. + management.metrics.export.datadog.num-threads=2 # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.datadog.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.datadog.step=1m # Step size (i.e. reporting frequency) to use. - management.metrics.export.datadog.uri= # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this. - management.metrics.export.ganglia.addressing-mode= # UDP addressing mode, either unicast or multicast. - management.metrics.export.ganglia.duration-units= # Base time unit used to report durations. - management.metrics.export.ganglia.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.ganglia.host= # Host of the Ganglia server to receive exported metrics. - management.metrics.export.ganglia.port= # Port of the Ganglia server to receive exported metrics. - management.metrics.export.ganglia.protocol-version= # Ganglia protocol version. Must be either 3.1 or 3.0. - management.metrics.export.ganglia.rate-units= # Base time unit used to report rates. - management.metrics.export.ganglia.step= # Step size (i.e. reporting frequency) to use. - management.metrics.export.ganglia.time-to-live= # Time to live for metrics on Ganglia. - management.metrics.export.graphite.duration-units= # Base time unit used to report durations. - management.metrics.export.graphite.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.graphite.host= # Host of the Graphite server to receive exported metrics. - management.metrics.export.graphite.port= # Port of the Graphite server to receive exported metrics. - management.metrics.export.graphite.protocol= # Protocol to use while shipping data to Graphite. - management.metrics.export.graphite.rate-units= # Base time unit used to report rates. - management.metrics.export.graphite.step= # Step size (i.e. reporting frequency) to use. + management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this. + management.metrics.export.ganglia.addressing-mode=multicast # UDP addressing mode, either unicast or multicast. + management.metrics.export.ganglia.duration-units=milliseconds # Base time unit used to report durations. + management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled. + management.metrics.export.ganglia.host=localhost # Host of the Ganglia server to receive exported metrics. + management.metrics.export.ganglia.port=8649 # Port of the Ganglia server to receive exported metrics. + management.metrics.export.ganglia.protocol-version=3.1 # Ganglia protocol version. Must be either 3.1 or 3.0. + management.metrics.export.ganglia.rate-units=seconds # Base time unit used to report rates. + management.metrics.export.ganglia.step=1m # Step size (i.e. reporting frequency) to use. + management.metrics.export.ganglia.time-to-live=1 # Time to live for metrics on Ganglia. Set the multi-cast Time-To-Live to be one greater than the number of hops (routers) between the hosts. + management.metrics.export.graphite.duration-units=milliseconds # Base time unit used to report durations. + management.metrics.export.graphite.enabled=true # Whether exporting of metrics to Graphite is enabled. + management.metrics.export.graphite.host=localhost # Host of the Graphite server to receive exported metrics. + management.metrics.export.graphite.port=2004 # Port of the Graphite server to receive exported metrics. + management.metrics.export.graphite.protocol=pickled # Protocol to use while shipping data to Graphite. + management.metrics.export.graphite.rate-units=seconds # Base time unit used to report rates. + management.metrics.export.graphite.step=1m # Step size (i.e. reporting frequency) to use. management.metrics.export.graphite.tags-as-prefix= # For the default naming convention, turn the specified tag keys into part of the metric prefix. - management.metrics.export.influx.auto-create-db= # Whether to create the Influx database if it does not exist before attempting to publish metrics to it. - management.metrics.export.influx.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. - management.metrics.export.influx.compressed= # Enable GZIP compression of metrics batches published to Influx. - management.metrics.export.influx.connect-timeout= # Connection timeout for requests to the backend. - management.metrics.export.influx.consistency= # Write consistency for each point. - management.metrics.export.influx.db= # Tag that will be mapped to "host" when shipping metrics to Influx. Can be omitted if host should be omitted on publishing. - management.metrics.export.influx.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.influx.num-threads= # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.influx.auto-create-db=true # Whether to create the Influx database if it does not exist before attempting to publish metrics to it. + management.metrics.export.influx.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.influx.compressed=true # Whether to enable GZIP compression of metrics batches published to Influx. + management.metrics.export.influx.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.influx.consistency=one # Write consistency for each point. + management.metrics.export.influx.db=mydb # Tag that will be mapped to "host" when shipping metrics to Influx. + management.metrics.export.influx.enabled=true # Whether exporting of metrics to this backend is enabled. + management.metrics.export.influx.num-threads=2 # Number of threads to use with the metrics publishing scheduler. management.metrics.export.influx.password= # Login password of the Influx server. - management.metrics.export.influx.read-timeout= # Read timeout for requests to the backend. + management.metrics.export.influx.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.influx.retention-policy= # Retention policy to use (Influx writes to the DEFAULT retention policy if one is not specified). management.metrics.export.influx.step=1m # Step size (i.e. reporting frequency) to use. - management.metrics.export.influx.uri= # URI of the Influx server. + management.metrics.export.influx.uri=http://localhost:8086 # URI of the Influx server. management.metrics.export.influx.user-name= # Login user of the Influx server. - management.metrics.export.jmx.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.jmx.step= # Step size (i.e. reporting frequency) to use. + management.metrics.export.jmx.enabled=true # Whether exporting of metrics to JMX is enabled. + management.metrics.export.jmx.step=1m # Step size (i.e. reporting frequency) to use. management.metrics.export.newrelic.account-id= # New Relic account ID. management.metrics.export.newrelic.api-key= # New Relic API key. - management.metrics.export.newrelic.batch-size= # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. - management.metrics.export.newrelic.connect-timeout= # Connection timeout for requests to this backend. - management.metrics.export.newrelic.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.newrelic.num-threads= # Number of threads to use with the metrics publishing scheduler. - management.metrics.export.newrelic.read-timeout= # Read timeout for requests to this backend. + management.metrics.export.newrelic.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.newrelic.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.newrelic.enabled=true # Whether exporting of metrics to this backend is enabled. + management.metrics.export.newrelic.num-threads=2 # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.newrelic.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.newrelic.step=1m # Step size (i.e. reporting frequency) to use. - management.metrics.export.newrelic.uri= # Optional custom URI for the New Relic Insights API. - management.metrics.export.prometheus.descriptions= # Enable publishing descriptions as part of the scrape payload to Prometheus. Turn this off to minimize the amount of data sent on each scrape. - management.metrics.export.prometheus.enabled=true # Whether exporting of metrics to this backend is enabled. - management.metrics.export.prometheus.step= # Step size (i.e. reporting frequency) to use. + management.metrics.export.newrelic.uri=https://insights-collector.newrelic.com # URI to ship metrics to. + management.metrics.export.prometheus.descriptions=true # Whether to enable publishing descriptions as part of the scrape payload to Prometheus. Turn this off to minimize the amount of data sent on each scrape. + management.metrics.export.prometheus.enabled=true # Whether exporting of metrics to Prometheus is enabled. + management.metrics.export.prometheus.step=1m # Step size (i.e. reporting frequency) to use. management.metrics.export.signalfx.access-token= # SignalFX access token. - management.metrics.export.signalfx.batch-size= # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. - management.metrics.export.signalfx.connect-timeout= # Connection timeout for requests to this backend. - management.metrics.export.signalfx.enabled= # Whether exporting of metrics to this backend is enabled. - management.metrics.export.signalfx.num-threads= # Number of threads to use with the metrics publishing scheduler. - management.metrics.export.signalfx.read-timeout= # Read timeout for requests to this backend. + management.metrics.export.signalfx.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.signalfx.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.signalfx.enabled=true # Whether exporting of metrics to this backend is enabled. + management.metrics.export.signalfx.num-threads=2 # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.signalfx.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.signalfx.source= # Uniquely identifies the app instance that is publishing metrics to SignalFx. Defaults to the local host name. - management.metrics.export.signalfx.step=1m # Step size (i.e. reporting frequency) to use. - management.metrics.export.signalfx.uri= # Optional custom URI for the SignalFX API. + management.metrics.export.signalfx.step=10s # Step size (i.e. reporting frequency) to use. + management.metrics.export.signalfx.uri=https://ingest.signalfx.com # URI to ship metrics to. + management.metrics.export.simple.enabled=true # Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled. management.metrics.export.simple.mode=cumulative # Counting mode. - management.metrics.export.simple.step=10s # Step size (i.e. reporting frequency) to use. - management.metrics.export.statsd.enabled=true # Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled. + management.metrics.export.simple.step=1m # Step size (i.e. reporting frequency) to use. + management.metrics.export.statsd.enabled=true # Whether exporting of metrics to StatsD is enabled. management.metrics.export.statsd.flavor=datadog # StatsD line protocol to use. management.metrics.export.statsd.host=localhost # Host of the StatsD server to receive exported metrics. management.metrics.export.statsd.max-packet-length=1400 # Total length of a single payload should be kept within your network's MTU. - management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed, it is sent to the StatsD server. + management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed (or publishUnchangedMeters is true), it is sent to the StatsD server. management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. + management.metrics.export.statsd.publish-unchanged-meters=true # Whether to send unchanged meters to the StatsD server. management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. management.metrics.export.wavefront.api-token= # API token used when publishing metrics directly to the Wavefront API host. - management.metrics.export.wavefront.enabled= # Whether exporting of metrics to this backend is enabled. + management.metrics.export.wavefront.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.wavefront.connect-timeout=1s # Connection timeout for requests to this backend. + management.metrics.export.wavefront.enabled=true # Whether exporting of metrics to this backend is enabled. management.metrics.export.wavefront.global-prefix= # Global prefix to separate metrics originating from this app's white box instrumentation from those originating from other Wavefront integrations when viewed in the Wavefront UI. + management.metrics.export.wavefront.num-threads=2 # Number of threads to use with the metrics publishing scheduler. + management.metrics.export.wavefront.read-timeout=10s # Read timeout for requests to this backend. management.metrics.export.wavefront.source= # Unique identifier for the app instance that is the source of metrics being published to Wavefront. Defaults to the local host name. - management.metrics.export.wavefront.uri= # URI to ship metrics to. + management.metrics.export.wavefront.step=10s # Step size (i.e. reporting frequency) to use. + management.metrics.export.wavefront.uri=https://longboard.wavefront.com # URI to ship metrics to. management.metrics.use-global-registry=true # Whether auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics. management.metrics.web.client.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter. management.metrics.web.client.record-request-percentiles=false # Whether instrumented requests record percentiles histogram buckets by default.