Skip to content

Commit

Permalink
docs: fix dbStats example in contrib/database/sql (#2669)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoffl01 committed Apr 25, 2024
1 parent c4f2942 commit 47fe650
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions contrib/database/sql/example_test.go
Expand Up @@ -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)
Expand Down

0 comments on commit 47fe650

Please sign in to comment.