From f478911c54d8a96807d553ca111abc387e5e821a Mon Sep 17 00:00:00 2001 From: Jon Schneider Date: Thu, 19 Jul 2018 00:08:09 -0500 Subject: [PATCH 1/4] Upgrade to Micrometer 1.0.6 See gh-13819 --- .../export/influx/InfluxProperties.java | 38 +++++++++++++++++++ .../influx/InfluxPropertiesConfigAdapter.java | 18 +++++++++ .../SignalFxPropertiesConfigAdapter.java | 1 + .../spring-boot-dependencies/pom.xml | 2 +- 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java index 0706c305ef1..94898d5645e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java @@ -57,6 +57,21 @@ public class InfluxProperties extends StepRegistryProperties { */ private String retentionPolicy; + /** + * Time period for which influx should retain data in the current database (e.g. 2h, 52w) + */ + private String retentionDuration; + + /** + * How many copies of the data are stored in the cluster. Must be 1 for a single node instance. + */ + private Integer retentionReplicationFactor; + + /** + * The time range covered by a shard group (e.g. 2h, 52w). + */ + private String retentionShardDuration; + /** * URI of the Influx server. */ @@ -137,4 +152,27 @@ public class InfluxProperties extends StepRegistryProperties { this.autoCreateDb = autoCreateDb; } + public String getRetentionDuration() { + return retentionDuration; + } + + public void setRetentionDuration(String retentionDuration) { + this.retentionDuration = retentionDuration; + } + + public Integer getRetentionReplicationFactor() { + return retentionReplicationFactor; + } + + public void setRetentionReplicationFactor(Integer retentionReplicationFactor) { + this.retentionReplicationFactor = retentionReplicationFactor; + } + + public String getRetentionShardDuration() { + return retentionShardDuration; + } + + public void setRetentionShardDuration(String retentionShardDuration) { + this.retentionShardDuration = retentionShardDuration; + } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java index e5145d3cfdf..1b8713348a4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java @@ -60,6 +60,24 @@ class InfluxPropertiesConfigAdapter extends InfluxConfig.super::retentionPolicy); } + @Override + public Integer retentionReplicationFactor() { + return get(InfluxProperties::getRetentionReplicationFactor, + InfluxConfig.super::retentionReplicationFactor); + } + + @Override + public String retentionDuration() { + return get(InfluxProperties::getRetentionDuration, + InfluxConfig.super::retentionDuration); + } + + @Override + public String retentionShardDuration() { + return get(InfluxProperties::getRetentionShardDuration, + InfluxConfig.super::retentionShardDuration); + } + @Override public String uri() { return get(InfluxProperties::getUri, InfluxConfig.super::uri); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesConfigAdapter.java index 721c1a52d8a..a3feda0fe63 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxPropertiesConfigAdapter.java @@ -32,6 +32,7 @@ public class SignalFxPropertiesConfigAdapter public SignalFxPropertiesConfigAdapter(SignalFxProperties properties) { super(properties); + accessToken(); // validate that an access token is set } @Override diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index b82c39c7282..00b9c95d294 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -122,7 +122,7 @@ 1.2.3 1.16.22 2.2.6 - 1.0.5 + 1.0.6 2.15.0 1.7.1 3.6.4 From ecb8da25361ca494de9e10d97dbc68fe2ed3bb62 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 24 Jul 2018 09:25:54 +0200 Subject: [PATCH 2/4] Polish "Upgrade to Micrometer 1.0.6" Closes gh-13819 --- .../export/influx/InfluxProperties.java | 57 ++++++++++--------- .../export/influx/InfluxPropertiesTests.java | 6 ++ .../appendix-application-properties.adoc | 3 + 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java index 94898d5645e..a09029e534f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java @@ -58,17 +58,21 @@ public class InfluxProperties extends StepRegistryProperties { private String retentionPolicy; /** - * Time period for which influx should retain data in the current database (e.g. 2h, 52w) + * Time period for which Influx should retain data in the current database. For + * instance 7d, check the influx documentation for more details on the duration + * format. */ private String retentionDuration; /** - * How many copies of the data are stored in the cluster. Must be 1 for a single node instance. + * How many copies of the data are stored in the cluster. Must be 1 for a single node + * instance. */ private Integer retentionReplicationFactor; /** - * The time range covered by a shard group (e.g. 2h, 52w). + * Time range covered by a shard group. For instance 2w, check the influx + * documentation for more details on the duration format. */ private String retentionShardDuration; @@ -128,6 +132,30 @@ public class InfluxProperties extends StepRegistryProperties { this.retentionPolicy = retentionPolicy; } + public String getRetentionDuration() { + return this.retentionDuration; + } + + public void setRetentionDuration(String retentionDuration) { + this.retentionDuration = retentionDuration; + } + + public Integer getRetentionReplicationFactor() { + return this.retentionReplicationFactor; + } + + public void setRetentionReplicationFactor(Integer retentionReplicationFactor) { + this.retentionReplicationFactor = retentionReplicationFactor; + } + + public String getRetentionShardDuration() { + return this.retentionShardDuration; + } + + public void setRetentionShardDuration(String retentionShardDuration) { + this.retentionShardDuration = retentionShardDuration; + } + public String getUri() { return this.uri; } @@ -152,27 +180,4 @@ public class InfluxProperties extends StepRegistryProperties { this.autoCreateDb = autoCreateDb; } - public String getRetentionDuration() { - return retentionDuration; - } - - public void setRetentionDuration(String retentionDuration) { - this.retentionDuration = retentionDuration; - } - - public Integer getRetentionReplicationFactor() { - return retentionReplicationFactor; - } - - public void setRetentionReplicationFactor(Integer retentionReplicationFactor) { - this.retentionReplicationFactor = retentionReplicationFactor; - } - - public String getRetentionShardDuration() { - return retentionShardDuration; - } - - public void setRetentionShardDuration(String retentionShardDuration) { - this.retentionShardDuration = retentionShardDuration; - } } 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 index 4d62674b11c..832a5c3abf8 100644 --- 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 @@ -39,6 +39,12 @@ public class InfluxPropertiesTests extends StepRegistryPropertiesTests { assertThat(properties.getUserName()).isEqualTo(config.userName()); assertThat(properties.getPassword()).isEqualTo(config.password()); assertThat(properties.getRetentionPolicy()).isEqualTo(config.retentionPolicy()); + assertThat(properties.getRetentionDuration()) + .isEqualTo(config.retentionDuration()); + assertThat(properties.getRetentionReplicationFactor()) + .isEqualTo(config.retentionReplicationFactor()); + assertThat(properties.getRetentionShardDuration()) + .isEqualTo(config.retentionShardDuration()); 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-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 8d55d0b70d7..9a796c4b106 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 @@ -1371,7 +1371,10 @@ content into your application. Rather, pick only the properties that you need. 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=10s # Read timeout for requests to this backend. + management.metrics.export.influx.retention-duration= # Time period for which Influx should retain data in the current database. + management.metrics.export.influx.retention-shard-duration= # Time range covered by a shard group. 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.retention-replication-factor= # How many copies of the data are stored in the cluster. management.metrics.export.influx.step=1m # Step size (i.e. reporting frequency) to use. 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. From ab1f8cf77bfd9945f6202b25e661426791049455 Mon Sep 17 00:00:00 2001 From: Johannes Edmeier Date: Wed, 18 Jul 2018 21:46:31 +0200 Subject: [PATCH 3/4] Add metric description and base unit to metrics endpoint See gh-13813 --- .../MetricsEndpointDocumentationTests.java | 2 ++ .../boot/actuate/metrics/MetricsEndpoint.java | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java index 604e052db7d..5e57f74e6d7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java @@ -54,6 +54,8 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat .andExpect(status().isOk()) .andDo(document("metrics/metric", responseFields( fieldWithPath("name").description("Name of the metric"), + fieldWithPath("description").description("Description of the metric"), + fieldWithPath("baseUnit").description("Base unit of the metric"), fieldWithPath("measurements") .description("Measurements of the metric"), fieldWithPath("measurements[].statistic") diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index c7055c3294d..a80f1ae3ea9 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -91,7 +91,9 @@ public class MetricsEndpoint { Map samples = getSamples(meters); Map> availableTags = getAvailableTags(meters); tags.forEach((t) -> availableTags.remove(t.getKey())); - return new MetricResponse(requiredMetricName, asList(samples, Sample::new), + Meter.Id meterId = meters.get(0).getId(); + return new MetricResponse(requiredMetricName, meterId.getDescription(), + meterId.getBaseUnit(), asList(samples, Sample::new), asList(availableTags, AvailableTag::new)); } @@ -183,13 +185,19 @@ public class MetricsEndpoint { private final String name; + private final String description; + + private final String baseUnit; + private final List measurements; private final List availableTags; - MetricResponse(String name, List measurements, - List availableTags) { + MetricResponse(String name, String description, String baseUnit, + List measurements, List availableTags) { this.name = name; + this.description = description; + this.baseUnit = baseUnit; this.measurements = measurements; this.availableTags = availableTags; } @@ -198,6 +206,14 @@ public class MetricsEndpoint { return this.name; } + public String getDescription() { + return this.description; + } + + public String getBaseUnit() { + return this.baseUnit; + } + public List getMeasurements() { return this.measurements; } From 7176c54f5e4aeac5c07fcc040f17ec3af34297f0 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 24 Jul 2018 09:03:03 +0200 Subject: [PATCH 4/4] Polish "Add metric description and base unit to metrics endpoint" Closes gh-13813 --- .../web/documentation/MetricsEndpointDocumentationTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java index 5e57f74e6d7..08baee11f6b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/MetricsEndpointDocumentationTests.java @@ -54,7 +54,8 @@ public class MetricsEndpointDocumentationTests extends MockMvcEndpointDocumentat .andExpect(status().isOk()) .andDo(document("metrics/metric", responseFields( fieldWithPath("name").description("Name of the metric"), - fieldWithPath("description").description("Description of the metric"), + fieldWithPath("description") + .description("Description of the metric"), fieldWithPath("baseUnit").description("Base unit of the metric"), fieldWithPath("measurements") .description("Measurements of the metric"),