Add StatsD transport protocol configuration option
See gh-22125
This commit is contained in:
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());
|
||||
|
||||
Reference in New Issue
Block a user