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

ddtrace/tracer: Add test to ensure global config inherits statsd address when configured with tracer.WithDogstatsdAddress #2683

Merged
merged 5 commits into from
Jul 5, 2024
Merged
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
16 changes: 16 additions & 0 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func TestAutoDetectStatsd(t *testing.T) {
require.NoError(t, err)
defer statsd.Close()
require.Equal(t, cfg.dogstatsdAddr, "unix://"+addr)
// Ensure globalconfig also gets the auto-detected UDS address
require.Equal(t, "unix://"+addr, globalconfig.DogstatsdAddr())
statsd.Count("name", 1, []string{"tag"}, 1)

buf := make([]byte, 17)
Expand Down Expand Up @@ -535,6 +537,20 @@ func TestTracerOptionsDefaults(t *testing.T) {
assert.Equal(t, c.dogstatsdAddr, "10.1.0.12:4002")
assert.Equal(t, globalconfig.DogstatsdAddr(), "10.1.0.12:4002")
})
t.Run("uds", func(t *testing.T) {
assert := assert.New(t)
dir, err := os.MkdirTemp("", "socket")
if err != nil {
t.Fatal("Failed to create socket")
}
addr := filepath.Join(dir, "dsd.socket")
defer os.RemoveAll(addr)
tracer := newTracer(WithDogstatsdAddress("unix://" + addr))
defer tracer.Stop()
c := tracer.config
assert.Equal("unix://"+addr, c.dogstatsdAddr)
assert.Equal("unix://"+addr, globalconfig.DogstatsdAddr())
})
})

t.Run("env-agentAddr", func(t *testing.T) {
Expand Down
Loading