sqlmw
sqlmw copied to clipboard
Interceptors for database/sql
Not sure if the libraries API is considered fully stable at this point, but it would be nice to have an actual semver version so that imports in go.mod don't...
Hello, I'm implementing an interceptor with sqlmw that records traces for database operations (instrumentedsql->sqlmw->tracing with sqlmw :-)). When a Rows, Stmt or Tx object is created I create a parent...
The interceptor lack callbacks for: * [`Driver.OpenConnector(name string) (driver.Connector, error)`](https://golang.org/pkg/database/sql/driver/#DriverContext) * [`Connector.Connect(context.Context) (driver.Conn, error)`](https://golang.org/pkg/database/sql/driver/#Connector) * [`Conn.Close() error`](https://golang.org/pkg/database/sql/driver/#Conn) I propose to add the following callbacks: * `OpenConnector(connector driver.DriverContext, name string) (driver.Connector,...
It would be useful to be able to get hold of the name used in the Open call, from inside the various methods of the interceptor. One option would be...
```golang func run(dsn string) { // install the wrapped driver sql.Register("postgres-mw", sqlmw.Driver(pq.Driver{}, new(sqlInterceptor))) db, err := sql.Open("postgres-mw", dsn) ... } type sqlInterceptor struct { sqlmw.NullInterceptor } func (in *sqlInterceptor) StmtQueryContext(ctx...
1. export `WrappedParentXXX` like Struct So that users can use ```go func (Interceptor)ConnExecContext(ctx context.Context, conn driver.ExecerContext, s string, values []driver.NamedValue) (ret driver.Result, err error) { // sqlmw wrapped wpConn,ok :=...
Depending on the driver we might have easy access to a configurable `driver.Connector`, but not a configurable `driver.Driver`. This change adds a couple new functions so we can wrap a...