collector

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithSQLAndPlanDigest

func CtxWithSQLAndPlanDigest(ctx context.Context, sqlDigest, planDigest []byte) context.Context

CtxWithSQLAndPlanDigest wrap the ctx with sql digest and plan digest.

func CtxWithSQLDigest

func CtxWithSQLDigest(ctx context.Context, sqlDigest []byte) context.Context

CtxWithSQLDigest wrap the ctx with sql 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

type SQLCPUTimeRecord struct {
	SQLDigest  []byte
	PlanDigest []byte
	CPUTimeMs  uint32
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL