11# ocsql
22
3- [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/ opencensus- integrations/ocsql )] ( https://goreportcard.com/report/github.com/ opencensus- integrations/ocsql )
4- [ ![ GoDoc] ( https://godoc.org/github.com/ opencensus- integrations/ocsql?status.svg )] ( https://godoc.org/github.com/ opencensus- integrations/ocsql )
3+ [ ![ Go Report Card] ( https://goreportcard.com/badge/contrib.go. opencensus.io/ integrations/ocsql )] ( https://goreportcard.com/report/contrib.go. opencensus.io/ integrations/ocsql )
4+ [ ![ GoDoc] ( https://godoc.org/contrib.go. opencensus.io/ integrations/ocsql?status.svg )] ( https://godoc.org/contrib.go. opencensus.io/ integrations/ocsql )
55[ ![ Sourcegraph] ( https://sourcegraph.com/github.com/opencensus-integrations/ocsql/-/badge.svg )] ( https://sourcegraph.com/github.com/opencensus-integrations/ocsql?badge )
66
77OpenCensus SQL database driver wrapper.
88
99Add an ocsql wrapper to your existing database code to instrument the
1010interactions with the database.
1111
12+ ## installation
13+
14+ go get -u contrib.go.opencensus.io/integrations/ocsql
15+
1216## initialize
1317
1418To use ocsql with your application, register an ocsql wrapper of a database
@@ -18,7 +22,7 @@ Example:
1822``` go
1923import (
2024 _ " github.com/mattn/go-sqlite3"
21- " github.com/ opencensus- integrations/ocsql"
25+ " contrib.go. opencensus.io/ integrations/ocsql"
2226)
2327
2428var (
@@ -45,7 +49,7 @@ Example:
4549``` go
4650import (
4751 sqlite3 " github.com/mattn/go-sqlite3"
48- " github.com/ opencensus- integrations/ocsql"
52+ " contrib.go. opencensus.io/ integrations/ocsql"
4953)
5054
5155var (
@@ -64,6 +68,22 @@ sql.Register("ocsql-sqlite3", driver)
6468db, err = sql.Open (" ocsql-sqlite3" , " resource.db" )
6569```
6670
71+ Projects providing their own abstractions on top of database/sql/driver can also
72+ wrap an existing driver.Conn interface directly with ocsql.
73+
74+ Example:
75+ ``` go
76+ import " contrib.go.opencensus.io/integrations/ocsql"
77+
78+ func GetConn (...) driver .Conn {
79+ // create custom driver.Conn
80+ conn := initializeConn (...)
81+
82+ // wrap with ocsql
83+ return ocsql.WrapConn (conn, ocsql.WithAllTraceOptions ())
84+ }
85+ ```
86+
6787## jmoiron/sqlx
6888
6989If using the ` sqlx ` library with named queries you will need to use the
0 commit comments