Skip to content

Commit

Permalink
internal/telemetry: fix flake in TestTelemetryEnabled (#3160)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahkm authored Feb 7, 2025
1 parent 4a72a09 commit 9462231
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ddtrace/tracer/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestTelemetryEnabled(t *testing.T) {
telemetry.Check(t, telemetryClient.Configuration, "span_sample_rules", "[]")
if metrics, ok := telemetryClient.Metrics[telemetry.NamespaceGeneral]; ok {
if initTime, ok := metrics["init_time"]; ok {
assert.True(t, initTime > 0)
assert.True(t, initTime > 0, "expected positive init time, but got %f", initTime)
return
}
t.Fatalf("could not find general init time in telemetry client metrics")
Expand Down
3 changes: 3 additions & 0 deletions internal/telemetry/telemetrytest/telemetrytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (c *MockClient) Record(ns telemetry.Namespace, _ telemetry.MetricKind, name
c.On("Gauge", ns, name, val, tags, common).Return()
c.On("Record", ns, name, val, tags, common).Return()
_ = c.Called(ns, name, val, tags, common)

c.mu.Lock()
defer c.mu.Unlock()
// record the val for tests that assert based on the value
if _, ok := c.Metrics[ns]; !ok {
c.Metrics[ns] = map[string]float64{}
Expand Down

0 comments on commit 9462231

Please sign in to comment.