Add StatsD transport protocol configuration option

See gh-22125
pull/22164/head
Lee Dobryden 4 years ago committed by Andy Wilkinson
parent 5de67e9b06
commit 5d41f60e45

@ -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;
}

@ -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<Stats
return get(StatsdProperties::getPort, StatsdConfig.super::port);
}
@Override
public StatsdProtocol protocol() {
return get(StatsdProperties::getProtocol, StatsdConfig.super::protocol);
}
@Override
public int maxPacketLength() {
return get(StatsdProperties::getMaxPacketLength, StatsdConfig.super::maxPacketLength);

@ -463,6 +463,10 @@
"name": "management.metrics.export.statsd.flavor",
"defaultValue": "datadog"
},
{
"name": "management.metrics.export.statsd.protocol",
"defaultValue": "udp"
},
{
"name": "management.metrics.export.statsd.queue-size",
"defaultValue": 2147483647,

@ -36,6 +36,7 @@ class StatsdPropertiesTests {
assertThat(properties.getFlavor()).isEqualTo(config.flavor());
assertThat(properties.getHost()).isEqualTo(config.host());
assertThat(properties.getPort()).isEqualTo(config.port());
assertThat(properties.getProtocol()).isEqualTo(config.protocol());
assertThat(properties.getMaxPacketLength()).isEqualTo(config.maxPacketLength());
assertThat(properties.getPollingFrequency()).isEqualTo(config.pollingFrequency());
assertThat(properties.isPublishUnchangedMeters()).isEqualTo(config.publishUnchangedMeters());

@ -1764,12 +1764,13 @@ 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 and port to use can be provided using:
The StatsD agent host,port, and protocol to use can be provided using:
[source,properties,indent=0,configprops]
----
management.metrics.export.statsd.host=statsd.example.com
management.metrics.export.statsd.port=9125
management.metrics.export.statsd.protocol=udp
----
You can also change the StatsD line protocol to use (default to Datadog):

Loading…
Cancel
Save