Skip to content

Commit

Permalink
ddtrace/tracer: initialize runtimeMetricsV2 with statsd "direct" clie…
Browse files Browse the repository at this point in the history
…nt (DataDog#3006)

Co-authored-by: Felix Geisendörfer <[email protected]>
Co-authored-by: Nayef Ghattas <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 7a7b85f commit 6004a6c
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 38 deletions.
2 changes: 1 addition & 1 deletion contrib/database/sql/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestCheckStatsdRequired(t *testing.T) {
cfg := new(config)
cfg.dbStats = true
cfg.checkStatsdRequired()
_, ok := cfg.statsdClient.(*statsd.Client)
_, ok := cfg.statsdClient.(*statsd.ClientDirect)
assert.True(t, ok)
})
t.Run("invalid address", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/mocktracer/mocktracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func newMockTracer() *mocktracer {
client := &http.Client{
Transport: t.dsmTransport,
}
t.dsmProcessor = datastreams.NewProcessor(&statsd.NoOpClient{}, "env", "service", "v1", &url.URL{Scheme: "http", Host: "agent-address"}, client)
t.dsmProcessor = datastreams.NewProcessor(&statsd.NoOpClientDirect{}, "env", "service", "v1", &url.URL{Scheme: "http", Host: "agent-address"}, client)
t.dsmProcessor.Start()
t.dsmProcessor.Flush()
return &t
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ func statsTags(c *config) []string {
// withNoopStats is used for testing to disable statsd client
func withNoopStats() StartOption {
return func(c *config) {
c.statsdClient = &statsd.NoOpClient{}
c.statsdClient = &statsd.NoOpClientDirect{}
}
}

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *concentrator) runFlusher(tick <-chan time.Time) {
// statsd returns any tracer configured statsd client, or a no-op.
func (c *concentrator) statsd() internal.StatsdClient {
if c.statsdClient == nil {
return &statsd.NoOpClient{}
return &statsd.NoOpClientDirect{}
}
return c.statsdClient
}
Expand Down
8 changes: 4 additions & 4 deletions ddtrace/tracer/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestConcentrator(t *testing.T) {
}
t.Run("start-stop", func(t *testing.T) {
assert := assert.New(t)
c := newConcentrator(&config{}, bucketSize, &statsd.NoOpClient{})
c := newConcentrator(&config{}, bucketSize, &statsd.NoOpClientDirect{})
assert.EqualValues(atomic.LoadUint32(&c.stopped), 1)
c.Start()
assert.EqualValues(atomic.LoadUint32(&c.stopped), 0)
Expand All @@ -60,7 +60,7 @@ func TestConcentrator(t *testing.T) {
t.Run("flusher", func(t *testing.T) {
t.Run("old", func(t *testing.T) {
transport := newDummyTransport()
c := newConcentrator(&config{transport: transport, env: "someEnv"}, 500_000, &statsd.NoOpClient{})
c := newConcentrator(&config{transport: transport, env: "someEnv"}, 500_000, &statsd.NoOpClientDirect{})
assert.Len(t, transport.Stats(), 0)
ss1, ok := c.newTracerStatSpan(&s1, nil)
assert.True(t, ok)
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestConcentrator(t *testing.T) {
t.Run("ciGitSha", func(t *testing.T) {
utils.AddCITags(constants.GitCommitSHA, "DEADBEEF")
transport := newDummyTransport()
c := newConcentrator(&config{transport: transport, env: "someEnv"}, (10 * time.Second).Nanoseconds(), &statsd.NoOpClient{})
c := newConcentrator(&config{transport: transport, env: "someEnv"}, (10 * time.Second).Nanoseconds(), &statsd.NoOpClientDirect{})
assert.Len(t, transport.Stats(), 0)
ss1, ok := c.newTracerStatSpan(&s1, nil)
assert.True(t, ok)
Expand All @@ -119,7 +119,7 @@ func TestConcentrator(t *testing.T) {
// stats should be sent if the concentrator is stopped
t.Run("stop", func(t *testing.T) {
transport := newDummyTransport()
c := newConcentrator(&config{transport: transport}, 500000, &statsd.NoOpClient{})
c := newConcentrator(&config{transport: transport}, 500000, &statsd.NoOpClientDirect{})
assert.Len(t, transport.Stats(), 0)
ss1, ok := c.newTracerStatSpan(&s1, nil)
assert.True(t, ok)
Expand Down
34 changes: 17 additions & 17 deletions ddtrace/tracer/textmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func TestEnvVars(t *testing.T) {
}
for _, test := range tests {
t.Run(fmt.Sprintf("inject with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
root := tracer.StartSpan("web.request").(*span)
ctx, ok := root.Context().(*spanContext)
Expand Down Expand Up @@ -743,7 +743,7 @@ func TestEnvVars(t *testing.T) {
}
for _, test := range tests {
t.Run(fmt.Sprintf("extract with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(test.in)
Expand Down Expand Up @@ -782,7 +782,7 @@ func TestEnvVars(t *testing.T) {
}
for _, tc := range tests {
t.Run(fmt.Sprintf("extract with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
_, err := tracer.Extract(tc.in)
Expand Down Expand Up @@ -839,7 +839,7 @@ func TestEnvVars(t *testing.T) {
}
for _, tc := range tests {
t.Run(fmt.Sprintf("extract with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.in)
Expand Down Expand Up @@ -876,7 +876,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("b3 single header inject #%d", i), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
root := tracer.StartSpan("myrequest").(*span)
ctx, ok := root.Context().(*spanContext)
Expand Down Expand Up @@ -934,7 +934,7 @@ func TestEnvVars(t *testing.T) {
}
for _, tc := range tests {
t.Run(fmt.Sprintf("inject with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithPropagator(NewPropagator(&PropagatorConfig{B3: true})), WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithPropagator(NewPropagator(&PropagatorConfig{B3: true})), WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
root := tracer.StartSpan("web.request").(*span)
ctx, ok := root.Context().(*spanContext)
Expand Down Expand Up @@ -1009,7 +1009,7 @@ func TestEnvVars(t *testing.T) {
}
for _, tc := range tests {
t.Run(fmt.Sprintf("extract with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)

Expand Down Expand Up @@ -1069,7 +1069,7 @@ func TestEnvVars(t *testing.T) {
}
for _, tc := range tests {
t.Run(fmt.Sprintf("inject and extract with env=%q", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
root := tracer.StartSpan("web.request").(*span)
root.SetTag(ext.SamplingPriority, -1)
Expand Down Expand Up @@ -1281,7 +1281,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%v extract/valid with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.in)
Expand Down Expand Up @@ -1337,7 +1337,7 @@ func TestEnvVars(t *testing.T) {

for i, tc := range tests {
t.Run(fmt.Sprintf("#%v extract/invalid with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc)
Expand Down Expand Up @@ -1389,7 +1389,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%v extract/valid with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.inHeaders)
Expand Down Expand Up @@ -1591,7 +1591,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%d w3c inject with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
root := tracer.StartSpan("web.request").(*span)
Expand Down Expand Up @@ -1621,7 +1621,7 @@ func TestEnvVars(t *testing.T) {
})

t.Run(fmt.Sprintf("w3c inject with env=%q / testing tag list-member limit", testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
root := tracer.StartSpan("web.request").(*span)
Expand Down Expand Up @@ -1689,7 +1689,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.inHeaders)
Expand Down Expand Up @@ -1764,7 +1764,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%d w3c inject/extract with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.in)
Expand Down Expand Up @@ -1828,7 +1828,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%d w3c inject/extract with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
pCtx, err := tracer.Extract(tc.in)
Expand Down Expand Up @@ -1911,7 +1911,7 @@ func TestEnvVars(t *testing.T) {
}
for i, tc := range tests {
t.Run(fmt.Sprintf("#%v extract with env=%q", i, testEnv), func(t *testing.T) {
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClient{}))
tracer := newTracer(WithHTTPClient(c), withStatsdClient(&statsd.NoOpClientDirect{}))
defer tracer.Stop()
assert := assert.New(t)
ctx, err := tracer.Extract(tc.in)
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ func TestFlush(t *testing.T) {
tr.statsd = ts

transport := newDummyTransport()
c := newConcentrator(&config{transport: transport, env: "someEnv"}, defaultStatsBucketSize, &statsd.NoOpClient{})
c := newConcentrator(&config{transport: transport, env: "someEnv"}, defaultStatsBucketSize, &statsd.NoOpClientDirect{})
tr.stats = c
c.Start()
defer c.Stop()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/DataDog/datadog-agent/pkg/trace v0.58.0
github.com/DataDog/datadog-go/v5 v5.5.0
github.com/DataDog/go-libddwaf/v3 v3.5.1
github.com/DataDog/go-runtime-metrics-internal v0.0.3
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6
github.com/DataDog/gostackparse v0.7.0
github.com/DataDog/sketches-go v1.4.5
github.com/IBM/sarama v1.40.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ github.com/DataDog/datadog-go/v5 v5.5.0 h1:G5KHeB8pWBNXT4Jtw0zAkhdxEAWSpWH00geHI
github.com/DataDog/datadog-go/v5 v5.5.0/go.mod h1:K9kcYBlxkcPP8tvvjZZKs/m1edNAUFzBbdpTUKfCsuw=
github.com/DataDog/go-libddwaf/v3 v3.5.1 h1:GWA4ln4DlLxiXm+X7HA/oj0ZLcdCwOS81KQitegRTyY=
github.com/DataDog/go-libddwaf/v3 v3.5.1/go.mod h1:n98d9nZ1gzenRSk53wz8l6d34ikxS+hs62A31Fqmyi4=
github.com/DataDog/go-runtime-metrics-internal v0.0.3 h1:AqzLCS4rqojBoCNwEAmbpLFAkKT43e+ze/a6aFbfDpU=
github.com/DataDog/go-runtime-metrics-internal v0.0.3/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 h1:bpitH5JbjBhfcTG+H2RkkiUXpYa8xSuIPnyNtTaSPog=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-sqllexer v0.0.14 h1:xUQh2tLr/95LGxDzLmttLgTo/1gzFeOyuwrQa/Iig4Q=
github.com/DataDog/go-sqllexer v0.0.14/go.mod h1:KwkYhpFEVIq+BfobkTC1vfqm4gTi65skV/DpDBXtexc=
github.com/DataDog/go-tuf v1.1.0-0.5.2 h1:4CagiIekonLSfL8GMHRHcHudo1fQnxELS9g4tiAupQ4=
Expand Down
2 changes: 1 addition & 1 deletion internal/apps/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/DataDog/datadog-agent/pkg/util/log v0.58.0 // indirect
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.58.0 // indirect
github.com/DataDog/go-libddwaf/v3 v3.5.1 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.3 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 // indirect
github.com/DataDog/go-sqllexer v0.0.14 // indirect
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.20.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
Expand Down
4 changes: 2 additions & 2 deletions internal/apps/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/DataDog/datadog-go/v5 v5.5.0 h1:G5KHeB8pWBNXT4Jtw0zAkhdxEAWSpWH00geHI
github.com/DataDog/datadog-go/v5 v5.5.0/go.mod h1:K9kcYBlxkcPP8tvvjZZKs/m1edNAUFzBbdpTUKfCsuw=
github.com/DataDog/go-libddwaf/v3 v3.5.1 h1:GWA4ln4DlLxiXm+X7HA/oj0ZLcdCwOS81KQitegRTyY=
github.com/DataDog/go-libddwaf/v3 v3.5.1/go.mod h1:n98d9nZ1gzenRSk53wz8l6d34ikxS+hs62A31Fqmyi4=
github.com/DataDog/go-runtime-metrics-internal v0.0.3 h1:AqzLCS4rqojBoCNwEAmbpLFAkKT43e+ze/a6aFbfDpU=
github.com/DataDog/go-runtime-metrics-internal v0.0.3/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 h1:bpitH5JbjBhfcTG+H2RkkiUXpYa8xSuIPnyNtTaSPog=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-sqllexer v0.0.14 h1:xUQh2tLr/95LGxDzLmttLgTo/1gzFeOyuwrQa/Iig4Q=
github.com/DataDog/go-sqllexer v0.0.14/go.mod h1:KwkYhpFEVIq+BfobkTC1vfqm4gTi65skV/DpDBXtexc=
github.com/DataDog/go-tuf v1.1.0-0.5.2 h1:4CagiIekonLSfL8GMHRHcHudo1fQnxELS9g4tiAupQ4=
Expand Down
2 changes: 1 addition & 1 deletion internal/datastreams/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func BenchmarkSetCheckpoint(b *testing.B) {
client := &http.Client{
Transport: &noOpTransport{},
}
p := NewProcessor(&statsd.NoOpClient{}, "env", "service", "v1", &url.URL{Scheme: "http", Host: "agent-address"}, client)
p := NewProcessor(&statsd.NoOpClientDirect{}, "env", "service", "v1", &url.URL{Scheme: "http", Host: "agent-address"}, client)
p.Start()
for i := 0; i < b.N; i++ {
p.SetCheckpointWithParams(context.Background(), options.CheckpointParams{PayloadSize: 1000}, "type:edge-1", "direction:in", "type:kafka", "topic:topic1", "group:group1")
Expand Down
2 changes: 1 addition & 1 deletion internal/exectracetest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.58.0 // indirect
github.com/DataDog/datadog-go/v5 v5.5.0 // indirect
github.com/DataDog/go-libddwaf/v3 v3.5.1 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.3 // indirect
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 // indirect
github.com/DataDog/go-sqllexer v0.0.14 // indirect
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.20.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions internal/exectracetest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/DataDog/datadog-go/v5 v5.5.0 h1:G5KHeB8pWBNXT4Jtw0zAkhdxEAWSpWH00geHI
github.com/DataDog/datadog-go/v5 v5.5.0/go.mod h1:K9kcYBlxkcPP8tvvjZZKs/m1edNAUFzBbdpTUKfCsuw=
github.com/DataDog/go-libddwaf/v3 v3.5.1 h1:GWA4ln4DlLxiXm+X7HA/oj0ZLcdCwOS81KQitegRTyY=
github.com/DataDog/go-libddwaf/v3 v3.5.1/go.mod h1:n98d9nZ1gzenRSk53wz8l6d34ikxS+hs62A31Fqmyi4=
github.com/DataDog/go-runtime-metrics-internal v0.0.3 h1:AqzLCS4rqojBoCNwEAmbpLFAkKT43e+ze/a6aFbfDpU=
github.com/DataDog/go-runtime-metrics-internal v0.0.3/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 h1:bpitH5JbjBhfcTG+H2RkkiUXpYa8xSuIPnyNtTaSPog=
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6/go.mod h1:quaQJ+wPN41xEC458FCpTwyROZm3MzmTZ8q8XOXQiPs=
github.com/DataDog/go-sqllexer v0.0.14 h1:xUQh2tLr/95LGxDzLmttLgTo/1gzFeOyuwrQa/Iig4Q=
github.com/DataDog/go-sqllexer v0.0.14/go.mod h1:KwkYhpFEVIq+BfobkTC1vfqm4gTi65skV/DpDBXtexc=
github.com/DataDog/go-tuf v1.1.0-0.5.2 h1:4CagiIekonLSfL8GMHRHcHudo1fQnxELS9g4tiAupQ4=
Expand Down
5 changes: 3 additions & 2 deletions internal/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type StatsdClient interface {
CountWithTimestamp(name string, value int64, tags []string, rate float64, timestamp time.Time) error
Gauge(name string, value float64, tags []string, rate float64) error
GaugeWithTimestamp(name string, value float64, tags []string, rate float64, timestamp time.Time) error
DistributionSamples(name string, values []float64, tags []string, rate float64) error
Timing(name string, value time.Duration, tags []string, rate float64) error
Flush() error
Close() error
Expand All @@ -29,9 +30,9 @@ func NewStatsdClient(addr string, globalTags []string) (StatsdClient, error) {
if addr == "" {
addr = DefaultDogstatsdAddr
}
client, err := statsd.New(addr, statsd.WithMaxMessagesPerPayload(40), statsd.WithTags(globalTags))
client, err := statsd.NewDirect(addr, statsd.WithMaxMessagesPerPayload(40), statsd.WithTags(globalTags))
if err != nil {
return &statsd.NoOpClient{}, err
return &statsd.NoOpClientDirect{}, err
}
return client, nil
}
7 changes: 7 additions & 0 deletions internal/statsdtest/statsdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"gopkg.in/DataDog/dd-trace-go.v1/internal"
)

type callType int64
Expand All @@ -24,6 +25,8 @@ const (
callTypeTiming
)

var _ internal.StatsdClient = &TestStatsdClient{}

type TestStatsdClient struct {
mu sync.RWMutex
gaugeCalls []TestStatsdCall
Expand Down Expand Up @@ -104,6 +107,10 @@ func (tg *TestStatsdClient) CountWithTimestamp(name string, value int64, tags []
})
}

func (tg *TestStatsdClient) DistributionSamples(_ string, _ []float64, _ []string, _ float64) error {
panic("not implemented")
}

func (tg *TestStatsdClient) Timing(name string, value time.Duration, tags []string, rate float64) error {
return tg.addMetric(callTypeTiming, tags, TestStatsdCall{
name: name,
Expand Down

0 comments on commit 6004a6c

Please sign in to comment.