Skip to content

Commit

Permalink
Remove use of testing.Testing()
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Dec 9, 2024
1 parent dbdc01a commit 79e9f93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 0 additions & 6 deletions ddtrace/tracer/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ package tracer

import (
"fmt"
"slices"
"strings"
"testing"

"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"
)
Expand Down Expand Up @@ -79,10 +77,6 @@ func startTelemetry(c *config) {
telemetryConfigs = append(telemetryConfigs, telemetry.Configuration{Name: "orchestrion_" + k, Value: v})
orchestrionEnabledTags = append(orchestrionEnabledTags, k+":"+v)
}
if testing.Testing() {
// In tests, ensure tags are consistently ordered... Ordering is irrelevant outside of tests.
slices.Sort(orchestrionEnabledTags)
}
}

// Apply the GlobalClient options...
Expand Down
11 changes: 7 additions & 4 deletions internal/telemetry/telemetrytest/telemetrytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package telemetrytest

import (
"slices"
"sync"

"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"
Expand Down Expand Up @@ -69,10 +70,12 @@ func (c *MockClient) productChange(namespace telemetry.Namespace, enabled bool)
}

// Record stores the value for the given metric. It is currently mocked for `Gauge` and `Distribution` metric types.
func (c *MockClient) Record(ns telemetry.Namespace, _ telemetry.MetricKind, name string, val float64, tags []string, common bool) {
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)
func (c *MockClient) Record(ns telemetry.Namespace, kind telemetry.MetricKind, name string, val float64, tags []string, common bool) {
// Ensure consistent ordering through expectations
slices.Sort(tags)

c.On("Record", ns, kind, name, val, tags, common).Return()
_ = c.Called(ns, kind, name, val, tags, common)
// record the val for tests that assert based on the value
if _, ok := c.Metrics[ns]; !ok {
if c.Metrics == nil {
Expand Down

0 comments on commit 79e9f93

Please sign in to comment.