Skip to content

Commit

Permalink
ddtrace/tracer: Add test to ensure global config inherits statsd addr…
Browse files Browse the repository at this point in the history
…ess when configured with tracer.WithDogstatsdAddress (#2683)
  • Loading branch information
mtoffl01 authored Jul 5, 2024
1 parent f00b4a7 commit 2664189
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 2664189

Please sign in to comment.