collector

package
v1.1.0-beta.0...-14a469a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithProcessInfo

func CtxWithProcessInfo(ctx context.Context, connID uint64, sqlID uint64) context.Context

CtxWithProcessInfo .

func CtxWithSQLAndPlanDigest

func CtxWithSQLAndPlanDigest(ctx context.Context, sqlDigest, planDigest string) context.Context

CtxWithSQLAndPlanDigest wrap the ctx with sql digest and plan digest.

func CtxWithSQLDigest

func CtxWithSQLDigest(ctx context.Context, sqlDigest string) 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 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

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