Tracing SQL queries with the X-Ray SDK for Go - Amazon X-Ray
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Tracing SQL queries with the X-Ray SDK for Go

To trace SQL calls to PostgreSQL or MySQL, replacing sql.Open calls to xray.SQLContext, as shown in the following example. Use URLs instead of configuration strings if possible.

Example main.go
func main() { db, err := xray.SQLContext("postgres", "postgres://user:password@host:port/db") row, err := db.QueryRowContext(ctx, "SELECT 1") // Use as normal }