diff --git a/cmd/refinery/main.go b/cmd/refinery/main.go index b2f6da9a2f..0690d96509 100644 --- a/cmd/refinery/main.go +++ b/cmd/refinery/main.go @@ -138,7 +138,7 @@ func main() { upstreamClient, err := libhoney.NewClient(libhoney.ClientConfig{ Transmission: &transmission.Honeycomb{ MaxBatchSize: c.GetMaxBatchSize(), - BatchTimeout: libhoney.DefaultBatchTimeout, + BatchTimeout: c.GetBatchTimeout(), MaxConcurrentBatches: libhoney.DefaultMaxConcurrentBatches, PendingWorkCapacity: uint(c.GetUpstreamBufferSize()), UserAgentAddition: userAgentAddition, @@ -156,7 +156,7 @@ func main() { peerClient, err := libhoney.NewClient(libhoney.ClientConfig{ Transmission: &transmission.Honeycomb{ MaxBatchSize: c.GetMaxBatchSize(), - BatchTimeout: libhoney.DefaultBatchTimeout, + BatchTimeout: c.GetBatchTimeout(), MaxConcurrentBatches: libhoney.DefaultMaxConcurrentBatches, PendingWorkCapacity: uint(c.GetPeerBufferSize()), UserAgentAddition: userAgentAddition, diff --git a/config/config.go b/config/config.go index 29e5c0e1e8..3212c85d3b 100644 --- a/config/config.go +++ b/config/config.go @@ -71,6 +71,9 @@ type Config interface { // complete before sending it, to allow stragglers to arrive GetSendDelay() (time.Duration, error) + // GetBatchTimeout returns how often to send off batches in seconds + GetBatchTimeout() time.Duration + // GetTraceTimeout is how long to wait before sending a trace even if it's // not complete. This should be longer than the longest expected trace // duration. diff --git a/config/file_config.go b/config/file_config.go index 74f210cc05..5e30aae6fb 100644 --- a/config/file_config.go +++ b/config/file_config.go @@ -37,6 +37,7 @@ type configContents struct { Sampler string `validate:"required,oneof= DeterministicSampler DynamicSampler EMADynamicSampler RulesBasedSampler TotalThroughputSampler"` Metrics string `validate:"required,oneof= prometheus honeycomb"` SendDelay time.Duration `validate:"required"` + BatchTimeout time.Duration TraceTimeout time.Duration `validate:"required"` MaxBatchSize uint `validate:"required"` SendTicker time.Duration `validate:"required"` @@ -135,6 +136,7 @@ func NewConfig(config, rules string, errorCallback func(error)) (Config, error) c.SetDefault("Collector", "InMemCollector") c.SetDefault("Metrics", "honeycomb") c.SetDefault("SendDelay", 2*time.Second) + c.SetDefault("BatchTimeout", libhoney.DefaultBatchTimeout) c.SetDefault("TraceTimeout", 60*time.Second) c.SetDefault("MaxBatchSize", 500) c.SetDefault("SendTicker", 100*time.Millisecond) @@ -710,6 +712,13 @@ func (f *fileConfig) GetSendDelay() (time.Duration, error) { return f.conf.SendDelay, nil } +func (f *fileConfig) GetBatchTimeout() time.Duration { + f.mux.RLock() + defer f.mux.RUnlock() + + return f.conf.BatchTimeout +} + func (f *fileConfig) GetTraceTimeout() (time.Duration, error) { f.mux.RLock() defer f.mux.RUnlock() diff --git a/config/mock.go b/config/mock.go index e17c5daa1e..83a4395a2d 100644 --- a/config/mock.go +++ b/config/mock.go @@ -57,6 +57,7 @@ type MockConfig struct { GetPrometheusMetricsConfigVal PrometheusMetricsConfig GetSendDelayErr error GetSendDelayVal time.Duration + GetBatchTimeoutVal time.Duration GetTraceTimeoutErr error GetTraceTimeoutVal time.Duration GetMaxBatchSizeVal uint @@ -258,6 +259,13 @@ func (m *MockConfig) GetSendDelay() (time.Duration, error) { return m.GetSendDelayVal, m.GetSendDelayErr } +func (m *MockConfig) GetBatchTimeout() time.Duration { + m.Mux.RLock() + defer m.Mux.RUnlock() + + return m.GetBatchTimeoutVal +} + func (m *MockConfig) GetTraceTimeout() (time.Duration, error) { m.Mux.RLock() defer m.Mux.RUnlock() diff --git a/config_complete.toml b/config_complete.toml index fe9e240756..3fdfdd6be5 100644 --- a/config_complete.toml +++ b/config_complete.toml @@ -58,6 +58,11 @@ HoneycombAPI = "https://api.honeycomb.io" # Eligible for live reload. SendDelay = "2s" +# BatchTimeout dictates how frequently to send unfulfilled batches. By default +# this will use the DefaultBatchTimeout in libhoney as its value, which is 100ms. +# Eligible for live reload. +BatchTimeout = "1s" + # TraceTimeout is a long timer; it represents the outside boundary of how long # to wait before sending an incomplete trace. Normally traces are sent when the # root span arrives. Sometimes the root span never arrives (due to crashes or