Documentation ¶
Index ¶
- Constants
- Variables
- func NewMongoDriverMonitor(m Monitor) *event.PoolMonitor
- type ConnOperation
- type DefaultPoolMonitor
- type ExecContextFunc
- type Logger
- type Monitor
- type MonitorType
- type PoolOperation
- type PrometheusPoolMonitor
- type QueryContextFunc
- type StatsDPoolMonitor
- type TracerOption
- type TracerWrapper
- func NewMongoQueryTracer(options ...TracerOption) *TracerWrapper
- func NewMsSQLTracerWrapper() *TracerWrapper
- func NewMsSQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper
- func NewMySQLTracerWrapper() *TracerWrapper
- func NewMySQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper
- func NewTracerWrapper(dbType string) *TracerWrapper
- type Wrapper
Constants ¶
const (
DEBUG_ENV = "DEBUG_MONITOR"
)
Variables ¶
var ( // RawQueryOption enable the raw query option // raw query option will convert the ? placeHolders to real data. // Once enabled, "SELECT a FROM b WHERE c = ?" will be "SELECT a FROM b WHERE c = d" RawQueryOption = rawQueryOption{} // IgnoreSelectColumnsOption enable the ignore select columns option // ignore select column option will ignore the select columns // Once enabled, "SELECT a,b FROM c WHERE d = ?" will be "SELECT ... FROM c WHERE d = ?" IgnoreSelectColumnsOption = ignoreSelectColumnsOption{} )
Functions ¶
func NewMongoDriverMonitor ¶
func NewMongoDriverMonitor(m Monitor) *event.PoolMonitor
Types ¶
type ConnOperation ¶
type ConnOperation uint8
const ( ConnCreate ConnOperation = iota + 1 ConnClose Connoccupy ConnRelease )
type DefaultPoolMonitor ¶
func (*DefaultPoolMonitor) Conn ¶
func (c *DefaultPoolMonitor) Conn(op ConnOperation) error
func (*DefaultPoolMonitor) Log ¶
func (c *DefaultPoolMonitor) Log(w io.Writer, a interface{})
func (*DefaultPoolMonitor) Pool ¶
func (c *DefaultPoolMonitor) Pool(op PoolOperation) error
type ExecContextFunc ¶
type ExecContextFunc func(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContextFunc defines the Exec function with context
type Monitor ¶
type Monitor interface { Logger Pool(PoolOperation) error Conn(ConnOperation) error }
func NewMongoPoolMonitor ¶
func NewMongoPoolMonitor(t MonitorType) Monitor
type PoolOperation ¶
type PoolOperation uint8
const ( PoolCreate PoolOperation = iota + 1 PoolClear )
type PrometheusPoolMonitor ¶
PrometheusMonitor is the prometheus based monitor but must be used with prometheus pushgateway
func NewPrometheusPoolMonitor ¶
func NewPrometheusPoolMonitor(appName string, gatewayAddress string) *PrometheusPoolMonitor
func (*PrometheusPoolMonitor) Conn ¶
func (c *PrometheusPoolMonitor) Conn(op ConnOperation) error
func (*PrometheusPoolMonitor) Log ¶
func (m *PrometheusPoolMonitor) Log(w io.Writer, args interface{})
func (*PrometheusPoolMonitor) Pool ¶
func (c *PrometheusPoolMonitor) Pool(op PoolOperation) error
type QueryContextFunc ¶
type QueryContextFunc func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContextFunc defines the Query function with context
type StatsDPoolMonitor ¶
type StatsDPoolMonitor struct {
// contains filtered or unexported fields
}
func NewStatsDPoolMonitor ¶
func NewStatsDPoolMonitor(appName string) *StatsDPoolMonitor
func (*StatsDPoolMonitor) Conn ¶
func (c *StatsDPoolMonitor) Conn(op ConnOperation) error
func (*StatsDPoolMonitor) Log ¶
func (m *StatsDPoolMonitor) Log(w io.Writer, args interface{})
func (*StatsDPoolMonitor) Pool ¶
func (c *StatsDPoolMonitor) Pool(op PoolOperation) error
type TracerOption ¶
TracerOption defines the wrapper's option
type TracerWrapper ¶
type TracerWrapper struct {
// contains filtered or unexported fields
}
TracerWrapper defines a tracer wrapper which impls WrapQueryContext and WrapExecContext
func NewMongoQueryTracer ¶
func NewMongoQueryTracer(options ...TracerOption) *TracerWrapper
func NewMsSQLTracerWrapper ¶
func NewMsSQLTracerWrapper() *TracerWrapper
NewMsSQLTracerWrapper init a default TracerWrapper with ignoreSelectColumnsOption
func NewMsSQLTracerWrapperWithOpts ¶
func NewMsSQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper
NewMsSQLTracerWrapperWithOpts init a pure TracerWrapper with set options
func NewMySQLTracerWrapper ¶
func NewMySQLTracerWrapper() *TracerWrapper
NewMySQLTracerWrapper init a default TracerWrapper with ignoreSelectColumnsOption
func NewMySQLTracerWrapperWithOpts ¶
func NewMySQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper
NewMySQLTracerWrapperWithOpts init a pure TracerWrapper with set options
func NewTracerWrapper ¶
func NewTracerWrapper(dbType string) *TracerWrapper
NewTracerWrapper new a default tracer wrapper with * ignore select columns option
func (*TracerWrapper) WrapExecContext ¶
func (t *TracerWrapper) WrapExecContext(fn ExecContextFunc, query string, args ...interface{}) ExecContextFunc
WrapExecContext impls wrapper's WrapExecContext
func (*TracerWrapper) WrapQueryContext ¶
func (t *TracerWrapper) WrapQueryContext(fn QueryContextFunc, query string, args ...interface{}) QueryContextFunc
WrapQueryContext impls wrapper's WrapQueryContext
type Wrapper ¶
type Wrapper interface { WrapQueryContext(fn QueryContextFunc, sql string, args ...interface{}) QueryContextFunc WrapExecContext(fn ExecContextFunc, sql string, args ...interface{}) ExecContextFunc }
Wrapper defines database common operations