From 47fe6502bdd61b903a299fd2f8b91470c43c00e5 Mon Sep 17 00:00:00 2001 From: Mikayla Toffler <46911781+mtoffl01@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:47:55 +0200 Subject: [PATCH] docs: fix dbStats example in contrib/database/sql (#2669) --- contrib/database/sql/example_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/database/sql/example_test.go b/contrib/database/sql/example_test.go index c0eb6a2e30..35b54f670d 100644 --- a/contrib/database/sql/example_test.go +++ b/contrib/database/sql/example_test.go @@ -108,14 +108,16 @@ func Example_dbmPropagation() { } func Example_dbStats() { - sqltrace.Register("postgres", &pq.Driver{}) + // Register the driver with the WithDBStats option to enable DBStats metric polling + sqltrace.Register("postgres", &pq.Driver{}, sqltrace.WithDBStats()) + // Followed by a call to Open. db, err := sqltrace.Open("postgres", "postgres://pqgotest:password@localhost/pqgotest?sslmode=disable") if err != nil { log.Fatal(err) } - // Tracing is now enabled. Continue to use the database/sql package as usual + // Tracing and metric polling is now enabled. Metrics will be submitted to Datadog with the prefix `datadog.tracer.sql` rows, err := db.Query("SELECT name FROM users WHERE age=?", 27) if err != nil { log.Fatal(err)