From 5d41f60e45bf4d88e2cdbfcf16b29aa2e17dc200 Mon Sep 17 00:00:00 2001 From: Lee Dobryden Date: Fri, 26 Jun 2020 16:21:20 -0400 Subject: [PATCH 1/2] Add StatsD transport protocol configuration option See gh-22125 --- .../metrics/export/statsd/StatsdProperties.java | 14 ++++++++++++++ .../statsd/StatsdPropertiesConfigAdapter.java | 6 ++++++ .../additional-spring-configuration-metadata.json | 4 ++++ .../export/statsd/StatsdPropertiesTests.java | 1 + .../docs/asciidoc/production-ready-features.adoc | 3 ++- 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java index dcaf939101..f41e5ce036 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java @@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.statsd; import java.time.Duration; import io.micrometer.statsd.StatsdFlavor; +import io.micrometer.statsd.StatsdProtocol; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -53,6 +54,11 @@ public class StatsdProperties { */ private Integer port = 8125; + /** + * Protocol of the StatsD server to receive exported metrics. + */ + private StatsdProtocol protocol = StatsdProtocol.UDP; + /** * Total length of a single payload should be kept within your network's MTU. */ @@ -102,6 +108,14 @@ public class StatsdProperties { this.port = port; } + public StatsdProtocol getProtocol() { + return this.protocol; + } + + public void setProtocol(StatsdProtocol protocol) { + this.protocol = protocol; + } + public Integer getMaxPacketLength() { return this.maxPacketLength; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java index 85961a759c..9913faa156 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java @@ -20,6 +20,7 @@ import java.time.Duration; import io.micrometer.statsd.StatsdConfig; import io.micrometer.statsd.StatsdFlavor; +import io.micrometer.statsd.StatsdProtocol; import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter; @@ -65,6 +66,11 @@ public class StatsdPropertiesConfigAdapter extends PropertiesConfigAdapter Date: Mon, 29 Jun 2020 09:46:53 +0100 Subject: [PATCH 2/2] Polish "Add StatsD transport protocol configuration option" See gh-22125 --- .../autoconfigure/metrics/export/statsd/StatsdProperties.java | 2 +- .../metrics/export/statsd/StatsdPropertiesTests.java | 2 +- .../src/docs/asciidoc/production-ready-features.adoc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java index f41e5ce036..7764813d87 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. 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 index da2f3602d5..ae1f6fc608 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index 0aff9dbba3..ede73b07b8 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -1764,7 +1764,7 @@ You can also change the interval at which metrics are sent to Stackdriver: ==== StatsD The StatsD registry pushes metrics over UDP to a StatsD agent eagerly. By default, metrics are exported to a {micrometer-registry-docs}/statsd[StatsD] agent running on your local machine. -The StatsD agent host,port, and protocol to use can be provided using: +The StatsD agent host, port, and protocol to use can be provided using: [source,properties,indent=0,configprops] ----