Skip to content

Commit

Permalink
disable DB stats feature until bug is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
katiehockman committed Mar 5, 2024
1 parent 63d7047 commit e9992c5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 61 deletions.
9 changes: 0 additions & 9 deletions contrib/database/sql/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,3 @@ func WithDBMPropagation(mode tracer.DBMPropagationMode) Option {
cfg.dbmPropagationMode = mode
}
}

// WithDBStats enables polling of DBStats metrics
// ref: https://pkg.go.dev/database/sql#DBStats
// These metrics are submitted to Datadog and are not billed as custom metrics
func WithDBStats() Option {
return func(cfg *config) {
cfg.dbStats = true
}
}
14 changes: 0 additions & 14 deletions contrib/database/sql/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,3 @@ func TestAnalyticsSettings(t *testing.T) {
assert.Equal(t, 0.2, cfg.analyticsRate)
})
}

func TestWithDBStats(t *testing.T) {
t.Run("default off", func(t *testing.T) {
cfg := new(config)
defaults(cfg, "", nil)
assert.False(t, cfg.dbStats)
})
t.Run("on", func(t *testing.T) {
cfg := new(config)
defaults(cfg, "", nil)
WithDBStats()(cfg)
assert.True(t, cfg.dbStats)
})
}
38 changes: 0 additions & 38 deletions contrib/database/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/sqltest"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/mocktracer"
"gopkg.in/DataDog/dd-trace-go.v1/internal"
"gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig"
"gopkg.in/DataDog/dd-trace-go.v1/internal/statsdtest"

mssql "github.com/denisenkom/go-mssqldb"
"github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -277,41 +274,6 @@ func TestOpenOptions(t *testing.T) {
s0 := spans[0]
assert.Equal(t, "register-override", s0.Tag(ext.ServiceName))
})

t.Run("WithDBStats", func(t *testing.T) {
Register(driverName, &pq.Driver{})
defer unregister(driverName)
_, err := Open(driverName, dsn, WithDBStats())
require.NoError(t, err)

var tg statsdtest.TestStatsdClient
sc := internal.NewStatsCarrier(&tg)
sc.Start()
defer sc.Stop()
globalconfig.SetStatsCarrier(sc)

// The polling interval has been reduced to 500ms for the sake of this test, so at least one round of `pollDBStats` should be complete in 1s
deadline := time.Now().Add(1 * time.Second)
wantStats := []string{MaxOpenConnections, OpenConnections, InUse, Idle, WaitCount, WaitDuration, MaxIdleClosed, MaxIdleTimeClosed, MaxLifetimeClosed}
for {
if time.Now().After(deadline) {
t.Fatalf("Stats not collected in expected interval of %v", interval)
}
calls := tg.CallNames()
// if the expected volume of stats has been collected, ensure 9/9 of the DB Stats are included
if len(calls) >= len(wantStats) {
for _, s := range wantStats {
if !assert.Contains(t, calls, s) {
t.Fatalf("Missing stat %s", s)
}
}
// all expected stats have been collected; exit out of loop, test should pass
break
}
// not all stats have been collected yet, try again in 50ms
time.Sleep(50 * time.Millisecond)
}
})
}

func TestMySQLUint64(t *testing.T) {
Expand Down

0 comments on commit e9992c5

Please sign in to comment.