Documentation ¶
Index ¶
- func CtxWithProcessInfo(ctx context.Context, connID uint64, sqlID uint64) context.Context
- func CtxWithSQLAndPlanDigest(ctx context.Context, sqlDigest, planDigest string) context.Context
- func CtxWithSQLDigest(ctx context.Context, sqlDigest string) context.Context
- type Collector
- type ProcessCPUTimeUpdater
- type SQLCPUCollector
- type SQLCPUTimeRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxWithProcessInfo ¶
CtxWithProcessInfo .
func CtxWithSQLAndPlanDigest ¶
CtxWithSQLAndPlanDigest wrap the ctx with sql digest and plan digest.
Types ¶
type Collector ¶
type Collector interface { // Collect uses to collect the SQL execution cpu time. Collect(stats []SQLCPUTimeRecord) }
Collector uses to collect SQL execution cpu time.
type ProcessCPUTimeUpdater ¶
type ProcessCPUTimeUpdater interface {
UpdateProcessCPUTime(connID uint64, sqlID uint64, cpuTime time.Duration)
}
ProcessCPUTimeUpdater Introduce this interface due to the dependency cycle
type SQLCPUCollector ¶
type SQLCPUCollector struct {
// contains filtered or unexported fields
}
SQLCPUCollector uses to consume cpu profile from globalCPUProfiler, then parse the SQL CPU usage from the cpu profile data. It is not thread-safe, should only be used in one goroutine.
func NewSQLCPUCollector ¶
func NewSQLCPUCollector(c Collector) *SQLCPUCollector
NewSQLCPUCollector create a SQLCPUCollector.
func (*SQLCPUCollector) SetProcessCPUUpdater ¶
func (sp *SQLCPUCollector) SetProcessCPUUpdater(updater ProcessCPUTimeUpdater)
SetProcessCPUUpdater sets the updater field
func (*SQLCPUCollector) Start ¶
func (sp *SQLCPUCollector) Start()
Start uses to start to run SQLCPUCollector. This will register a consumer into globalCPUProfiler, then SQLCPUCollector will receive cpu profile data per seconds. WARN: this function is not thread-safe.
func (*SQLCPUCollector) Stop ¶
func (sp *SQLCPUCollector) Stop()
Stop uses to stop the SQLCPUCollector. WARN: this function is not thread-safe.
type SQLCPUTimeRecord ¶
SQLCPUTimeRecord represents a single record of how much cpu time a sql plan consumes in one second.
PlanDigest can be empty, because: 1. some sql statements has no plan, like `COMMIT` 2. when a sql statement is being compiled, there's no plan yet