Documentation ¶
Overview ¶
Package sqlxtraced provides a traced version of the "jmoiron/sqlx" package For more information about the API, see https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced.
Example ¶
The API to trace sqlx calls is the same as sqltraced. See https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced for more information on how to use it.
package main import ( "github.com/jmoiron/sqlx" "github.com/lib/pq" "github.com/DataDog/dd-trace-go/tracer/contrib/sqlxtraced" ) func main() { // OpenTraced will first register a traced version of the driver and then will return the sqlx.DB object // that holds the connection with the database. // The third argument is used to specify the name of the service under which traces will appear in the Datadog app. db, _ := sqlxtraced.OpenTraced(&pq.Driver{}, "postgres://pqgotest:password@localhost/pqgotest?sslmode=disable", "web-backend") // All calls through sqlx API will then be traced. query, args, _ := sqlx.In("SELECT * FROM users WHERE level IN (?);", []int{4, 6, 7}) query = db.Rebind(query) rows, _ := db.Query(query, args...) defer rows.Close() }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenTraced ¶
func OpenTraced(driver driver.Driver, dataSourceName, service string, trcv ...*tracer.Tracer) (*sqlx.DB, error)
OpenTraced will first register the traced version of the `driver` if not yet registered and will then open a connection with it. This is usually the only function to use when there is no need for the granularity offered by Register and Open. The last argument is optional and allows you to pass a custom tracer.
Types ¶
This section is empty.