Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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) 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