Skip to content

Commit edf5d53

Browse files
committed
Fix tests
1 parent aa51e23 commit edf5d53

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

ddtrace/tracer/telemetry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func startTelemetry(c *config) {
121121
}
122122
telemetry.GlobalClient.Count(
123123
telemetry.NamespaceTracers,
124-
"orchestrion_usage", 1,
124+
"orchestrion.enabled", 1,
125125
tags,
126126
false, // Go-specific
127127
)

ddtrace/tracer/telemetry_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,17 @@ func TestTelemetryEnabled(t *testing.T) {
154154
telemetryClient := new(telemetrytest.MockClient)
155155
defer telemetry.MockGlobalClient(telemetryClient)()
156156

157-
telemetryClient.On("Count",
158-
telemetry.NamespaceTracers,
159-
"orchestrion_usage", 1.0,
160-
[]string{"k1:v1", "k2:v2"},
161-
false,
162-
).Return()
163-
164157
Start(WithOrchestrion(map[string]string{"k1": "v1", "k2": "v2"}))
165158
defer Stop()
166159

167160
telemetry.Check(t, telemetryClient.Configuration, "orchestrion_enabled", true)
168161
telemetry.Check(t, telemetryClient.Configuration, "orchestrion_k1", "v1")
169162
telemetry.Check(t, telemetryClient.Configuration, "orchestrion_k2", "v2")
170-
telemetryClient.AssertExpectations(t)
163+
telemetryClient.AssertCalled(t, "Count",
164+
telemetry.NamespaceTracers,
165+
"orchestrion.enabled", 1.0,
166+
[]string{"k1:v1", "k2:v2"},
167+
false,
168+
)
171169
})
172170
}

internal/telemetry/telemetrytest/telemetrytest.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ func (c *MockClient) Record(ns telemetry.Namespace, _ telemetry.MetricKind, name
7575
_ = c.Called(ns, name, val, tags, common)
7676
// record the val for tests that assert based on the value
7777
if _, ok := c.Metrics[ns]; !ok {
78+
if c.Metrics == nil {
79+
c.Metrics = make(map[telemetry.Namespace]map[string]float64)
80+
}
7881
c.Metrics[ns] = map[string]float64{}
7982
}
8083
c.Metrics[ns][name] = val
8184
}
8285

8386
// Count counts the value for the given metric
8487
func (c *MockClient) Count(ns telemetry.Namespace, name string, val float64, tags []string, common bool) {
88+
c.On("Count", ns, name, val, tags, common).Return()
8589
_ = c.Called(ns, name, val, tags, common)
8690
}
8791

0 commit comments

Comments
 (0)