Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: gossip config reload information #1241

Merged
merged 9 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/refinery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/honeycombio/refinery/app"
"github.com/honeycombio/refinery/collect"
"github.com/honeycombio/refinery/config"
"github.com/honeycombio/refinery/internal/configwatcher"
"github.com/honeycombio/refinery/internal/health"
"github.com/honeycombio/refinery/internal/otelutil"
"github.com/honeycombio/refinery/internal/peer"
Expand Down Expand Up @@ -266,6 +267,7 @@ func main() {
{Value: samplerFactory},
{Value: stressRelief, Name: "stressRelief"},
{Value: &health.Health{}},
{Value: &configwatcher.ConfigWatcher{}},
{Value: &a},
}
err = g.Provide(objects...)
Expand Down
9 changes: 5 additions & 4 deletions collect/collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ func TestAddRootSpan(t *testing.T) {
},
}
coll.AddSpan(span)

time.Sleep(conf.SendTickerVal * 2)

// adding one span with no parent ID should:
// * create the trace in the cache
// * send the trace
// * remove the trace from the cache
// * remove the trace from the cache
assert.Nil(t, coll.getFromCache(traceID1), "after sending the span, it should be removed from the cache")
transmission.Mux.RLock()
assert.Equal(t, 1, len(transmission.Events), "adding a root span should send the span")
Expand Down Expand Up @@ -508,7 +509,7 @@ func TestCacheSizeReload(t *testing.T) {
conf.Mux.Lock()
conf.GetCollectionConfigVal.CacheCapacity = 2
conf.Mux.Unlock()
conf.ReloadConfig()
conf.Reload()

assert.Eventually(t, func() bool {
coll.mutex.RLock()
Expand All @@ -525,7 +526,7 @@ func TestCacheSizeReload(t *testing.T) {
conf.Mux.Lock()
conf.GetCollectionConfigVal.CacheCapacity = 1
conf.Mux.Unlock()
conf.ReloadConfig()
conf.Reload()

expectedEvents = 2
assert.Eventually(t, check, 60*wait, wait, "expected another trace evicted and sent")
Expand Down Expand Up @@ -574,7 +575,7 @@ func TestSampleConfigReload(t *testing.T) {
return ok
}, conf.GetTraceTimeoutVal*2, conf.SendTickerVal)

conf.ReloadConfig()
conf.Reload()

assert.Eventually(t, func() bool {
coll.mutex.Lock()
Expand Down
21 changes: 15 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ const (

// Config defines the interface the rest of the code uses to get items from the
// config. There are different implementations of the config using different
// backends to store the config. FileConfig is the default and uses a
// TOML-formatted config file. RedisPeerFileConfig uses a redis cluster to store
// the list of peers and then falls back to a filesystem config file for all
// other config elements.
// backends to store the config.

type Config interface {
// RegisterReloadCallback takes a name and a function that will be called
// when the configuration is reloaded. This will happen infrequently. If
// whenever the configuration is reloaded. This will happen infrequently. If
// consumers of configuration set config values on startup, they should
// check their values haven't changed and re-start anything that needs
// restarting with the new values.
// restarting with the new values. The callback is passed the two hashes
// for config and rules so that the caller can decide if they need to
// reconfigure anything.
RegisterReloadCallback(callback ConfigReloadCallback)

// Reload forces the config to attempt to reload its values. If the config
// checksum has changed, the reload callbacks will be called.
Reload()

// GetHashes returns the current config and rule hashes
GetHashes() (cfg string, rules string)

// GetListenAddr returns the address and port on which to listen for
// incoming events
GetListenAddr() (string, error)
Expand Down Expand Up @@ -128,6 +134,9 @@ type Config interface {
// GetAllSamplerRules returns all rules in a single map, including the default rules
GetAllSamplerRules() (*V2SamplerConfig, error)

// GetGeneralConfig returns the config specific to General
GetGeneralConfig() GeneralConfig

// GetLegacyMetricsConfig returns the config specific to LegacyMetrics
GetLegacyMetricsConfig() LegacyMetricsConfig

Expand Down
Loading
Loading