mirror of https://github.com/hashicorp/consul
Do not default in two conditions 1) preconfigured sinks exist 2) preconfigured flush interval exists
parent
5d597a3b53
commit
a6e8c5a935
|
@ -251,8 +251,9 @@ func (c *BootstrapConfig) ConfigureArgs(args *BootstrapTplArgs, omitDeprecatedTa
|
|||
|
||||
// Setup telemetry collector if needed. This MUST happen after the Static*JSON is set above
|
||||
if c.TelemetryCollectorBindSocketDir != "" {
|
||||
// Unless configured, override StatsFlushInterval as 60 seconds (1 minute) to reduce number of metric flushes.
|
||||
if c.StatsFlushInterval == "" {
|
||||
// Override StatsFlushInterval as 60 seconds (1 minute) to reduce number of metric flushes.
|
||||
// Only perform this override if there is no custom configuration for stats sinks and flush interval.
|
||||
if c.StatsFlushInterval == "" && args.StatsSinksJSON == "" {
|
||||
args.StatsFlushInterval = "60s"
|
||||
}
|
||||
appendTelemetryCollectorConfig(args, c.TelemetryCollectorBindSocketDir)
|
||||
|
|
|
@ -5,6 +5,7 @@ package envoy
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -637,11 +638,12 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) {
|
|||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "telemetry-collector-with-flush-interval-configured",
|
||||
name: "telemetry-collector-no-default-flush-interval-when-interval-preconfigured",
|
||||
baseArgs: BootstrapTplArgs{
|
||||
ProxyID: "web-sidecar-proxy",
|
||||
},
|
||||
input: BootstrapConfig{
|
||||
// Explicitly defined StatsFlushInterval by end user should not be overriden.
|
||||
StatsFlushInterval: "10s",
|
||||
TelemetryCollectorBindSocketDir: "/tmp/consul/telemetry-collector",
|
||||
},
|
||||
|
@ -653,6 +655,24 @@ func TestBootstrapConfig_ConfigureArgs(t *testing.T) {
|
|||
StaticClustersJSON: expectedTelemetryCollectorCluster,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "telemetry-collector-no-default-flush-interval-when-sinks-preconfigured",
|
||||
baseArgs: BootstrapTplArgs{
|
||||
ProxyID: "web-sidecar-proxy",
|
||||
},
|
||||
input: BootstrapConfig{
|
||||
// If stats sinks are explicitly defined by end user, do not default StatsFlushInterval.
|
||||
StatsdURL: "udp://127.0.0.1:9125",
|
||||
TelemetryCollectorBindSocketDir: "/tmp/consul/telemetry-collector",
|
||||
},
|
||||
wantArgs: BootstrapTplArgs{
|
||||
StatsFlushInterval: "",
|
||||
ProxyID: "web-sidecar-proxy",
|
||||
StatsConfigJSON: defaultStatsConfigJSON,
|
||||
StatsSinksJSON: fmt.Sprintf(`%s,%s`, expectedStatsdSink, expectedTelemetryCollectorStatsSink),
|
||||
StaticClustersJSON: expectedTelemetryCollectorCluster,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "simple-statsd-sink",
|
||||
input: BootstrapConfig{
|
||||
|
|
Loading…
Reference in New Issue