TraceOptions holds configuration of our ocsql tracing middleware.
By default all options are set to false intentionally when creating a wrapped
driver and provide the most sensible default with both performance and
security in mind.
AllowRoot, if set to true, will allow ocsql to create root spans in
absence of existing spans or even context.
Default is to not trace ocsql calls if no existing parent span is found
in context or when using methods not taking context.
DefaultAttributes will be set to each span as default.
LastInsertID, if set to true, will enable the creation of spans on
LastInsertId calls.
Ping, if set to true, will enable the creation of spans on Ping requests.
Query, if set to true, will enable recording of sql queries in spans.
Only allow this if it is safe to have queries recorded with respect to
security.
QueryParams, if set to true, will enable recording of parameters used
with parametrized queries. Only allow this if it is safe to have
parameters recorded with respect to security.
This setting is a noop if the Query option is set to false.
RowsAffected, if set to true, will enable the creation of spans on
RowsAffected calls.
RowsClose, if set to true, will enable the creation of spans on RowsClose
calls.
RowsNext, if set to true, will enable the creation of spans on RowsNext
calls. This can result in many spans.
func WithOptions(options TraceOptions) TraceOption
func wrapConn(parent driver.Conn, options TraceOptions) driver.Conn
func wrapDriver(d driver.Driver, o TraceOptions) driver.Driver
func wrapRows(ctx context.Context, parent driver.Rows, options TraceOptions) driver.Rows
func wrapStmt(stmt driver.Stmt, query string, options TraceOptions) driver.Stmt
var AllTraceOptions
Begin starts and returns a new transaction.
Deprecated: Drivers should implement ConnBeginTx instead (or additionally).
BeginTx starts and returns a new transaction.
If the context is canceled by the user the sql package will
call Tx.Rollback before discarding and closing the connection.
This must check opts.Isolation to determine if there is a set
isolation level. If the driver does not support a non-default
level and one is set or if there is a non-default isolation level
that is not supported, an error must be returned.
This must also check opts.ReadOnly to determine if the read-only
value is true to either set the read-only transaction property if supported
or return an error if it is not supported.
Close invalidates and potentially stops any current
prepared statements and transactions, marking this
connection as no longer in use.
Because the sql package maintains a free pool of
connections and only calls Close when there's a surplus of
idle connections, it shouldn't be necessary for drivers to
do their own connection caching.
Drivers must ensure all network calls made by Close
do not block indefinitely (e.g. apply a timeout).
( T) Exec(query string, args []driver.Value) (driver.Result, error)( T) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)( T) Ping(ctx context.Context) error
Prepare returns a prepared statement, bound to this connection.
PrepareContext returns a prepared statement, bound to this connection.
context is for the preparation of the statement,
it must not store the context within the statement itself.
( T) Query(query string, args []driver.Value) (driver.Rows, error)( T) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
*ocConn
T : database/sql/driver.Conn
T : database/sql/driver.ConnBeginTx
T : database/sql/driver.ConnPrepareContext
T : database/sql/driver.Execer
T : database/sql/driver.ExecerContext
T : database/sql/driver.Pinger
T : database/sql/driver.Queryer
T : database/sql/driver.QueryerContext
T : io.Closer
T : golang.org/x/pkgsite/internal/database.iconn
ocRows implements driver.Rows and all enhancement interfaces except
driver.RowsColumnTypeScanType.
ctxcontext.ContextoptionsTraceOptionsparentdriver.Rows( T) Close() (err error)
ColumnTypeDatabaseTypeName calls the implements the driver.RowsColumnTypeDatabaseTypeName for ocRows.
It returns the the underlying result of ColumnTypeDatabaseTypeName from the ocRows.parent
if the parent implements driver.RowsColumnTypeDatabaseTypeName.
ColumnTypeLength calls the implements the driver.RowsColumnTypeLength for ocRows.
It returns the the underlying result of ColumnTypeLength from the ocRows.parent
if the parent implements driver.RowsColumnTypeLength.
ColumnTypeNullable calls the implements the driver.RowsColumnTypeNullable for ocRows.
It returns the the underlying result of ColumnTypeNullable from the ocRows.parent
if the parent implements driver.RowsColumnTypeNullable.
ColumnTypePrecisionScale calls the implements the driver.RowsColumnTypePrecisionScale for ocRows.
It returns the the underlying result of ColumnTypePrecisionScale from the ocRows.parent
if the parent implements driver.RowsColumnTypePrecisionScale.
( T) Columns() []string
HasNextResultSet calls the implements the driver.RowsNextResultSet for ocRows.
It returns the the underlying result of HasNextResultSet from the ocRows.parent
if the parent implements driver.RowsNextResultSet.
( T) Next(dest []driver.Value) (err error)
NextResultsSet calls the implements the driver.RowsNextResultSet for ocRows.
It returns the the underlying result of NextResultSet from the ocRows.parent
if the parent implements driver.RowsNextResultSet.
T : database/sql/driver.Rows
T : database/sql/driver.RowsColumnTypeDatabaseTypeName
T : database/sql/driver.RowsColumnTypeLength
T : database/sql/driver.RowsColumnTypeNullable
T : database/sql/driver.RowsColumnTypePrecisionScale
T : database/sql/driver.RowsNextResultSet
T : io.Closer
withRowsColumnTypeScanType is the same as the driver.RowsColumnTypeScanType
interface except it omits the driver.Rows embedded interface.
If the original driver.Rows implementation wrapped by ocsql supports
RowsColumnTypeScanType we enable the original method implementation in the
returned driver.Rows from wrapRows by doing a composition with ocRows.
( T) ColumnTypeScanType(index int) reflect.Type
database/sql/driver.RowsColumnTypeScanType(interface)
*github.com/jackc/pgx/v4/stdlib.Rows
*github.com/lib/pq.rows
Package-Level Functions (total 26, in which 17 are exported)
RecordStats records database statistics for provided sql.DB at the provided
interval.
Register initializes and registers our ocsql wrapped database driver
identified by its driverName and using provided TraceOptions. On success it
returns the generated driverName to use when calling sql.Open.
It is possible to register multiple wrappers for the same database driver if
needing different TraceOptions for different connections.
RegisterAllViews registers all ocsql views to enable collection of stats.
WithAllowRoot if set to true, will allow ocsql to create root spans in
absence of exisiting spans or even context.
Default is to not trace ocsql calls if no existing parent span is found
in context or when using methods not taking context.
WithAllTraceOptions enables all available trace options.
WithDefaultAttributes will be set to each span as default.
WithLastInsertID if set to true, will enable the creation of spans on
LastInsertId calls.
WithOptions sets our ocsql tracing middleware options through a single
TraceOptions object.
WithPing if set to true, will enable the creation of spans on Ping requests.
WithQuery if set to true, will enable recording of sql queries in spans.
Only allow this if it is safe to have queries recorded with respect to
security.
WithQueryParams if set to true, will enable recording of parameters used
with parametrized queries. Only allow this if it is safe to have
parameters recorded with respect to security.
This setting is a noop if the Query option is set to false.
WithRowsAffected if set to true, will enable the creation of spans on
RowsAffected calls.
WithRowsClose if set to true, will enable the creation of spans on RowsClose
calls.
WithRowsNext if set to true, will enable the creation of spans on RowsNext
calls. This can result in many spans.
Wrap takes a SQL driver and wraps it with OpenCensus instrumentation.
WrapConn allows an existing driver.Conn to be wrapped by ocsql.
WrapConnector allows wrapping a database driver.Connector which eliminates
the need to register ocsql as an available driver.Driver.
wrapRows returns a struct which conforms to the driver.Rows interface.
ocRows implements all enhancement interfaces that have no effect on
sql/database logic in case the underlying parent implementation lacks them.
Currently the one exception is RowsColumnTypeScanType which does not have a
valid zero value. This interface is tested for and only enabled in case the
parent implementation supports it.
Package-Level Variables (total 29, in which 23 are exported)
AllTraceOptions has all tracing options enabled.
Default distributions used by views in this package
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
GoSQLError is the error received while calling a SQL method.
GoSQLMethod is the SQL method called.
GoSQLStatus identifies success vs. error from the SQL method response.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
The following measures are supported for use in custom views.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
Package ocsql provides some convenience views.
You still need to register these views for data to actually be collected.
You can use the RegisterAllViews function for this.
The following tags are applied to stats recorded by this package.
The following tags are applied to stats recorded by this package.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.