Documentation ¶
Overview ¶
Package sqlstats implements an SQLite Tracer that collects query stats.
Index ¶
- type QueryStats
- type Tracer
- func (t *Tracer) BeginTx(beginCtx context.Context, id sqliteh.TraceConnID, why string, readOnly bool, ...)
- func (t *Tracer) Collect() (rows []*QueryStats)
- func (t *Tracer) Commit(id sqliteh.TraceConnID, err error)
- func (t *Tracer) Handle(w http.ResponseWriter, r *http.Request)
- func (t *Tracer) HandleConns(w http.ResponseWriter, r *http.Request)
- func (t *Tracer) Query(prepCtx context.Context, id sqliteh.TraceConnID, query string, ...)
- func (t *Tracer) Reset()
- func (t *Tracer) Rollback(id sqliteh.TraceConnID, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QueryStats ¶
type QueryStats struct { Query string // Count represents the number of times this query has been // executed. Count int64 // Errors represents the number of errors encountered executing // this query. Errors int64 // TotalDuration represents the accumulated time spent executing the query. TotalDuration time.Duration // MeanDuration represents the average time spent executing the query. MeanDuration time.Duration }
QueryStats is a collection of stats for a given Query.
type Tracer ¶
type Tracer struct { TxCount *expvar.Map TxCommit *expvar.Map TxCommitError *expvar.Map TxRollback *expvar.Map TxTotalSeconds *expvar.Map // contains filtered or unexported fields }
Tracer implements sqlite.Tracer and collects query stats.
To use, pass the tracer object to sqlite.Connector, then start a debug web server with http.HandlerFunc(sqlTracer.Handle).
func (*Tracer) Collect ¶
func (t *Tracer) Collect() (rows []*QueryStats)
Collect returns the list of QueryStats pointers from the Tracer.
func (*Tracer) HandleConns ¶
func (t *Tracer) HandleConns(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.