reporter

package
v1.1.0-beta.0...-457dcc6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSink

type DataSink interface {
	// TrySend pushes a report data into the sink, which will later be sent to a target by the sink. A deadline can be
	// specified to control how late it should be sent. If the sink is kept full and cannot schedule a send within
	// the specified deadline, or the sink is closed, an error will be returned.
	TrySend(data *ReportData, deadline time.Time) error

	// OnReporterClosing notifies DataSink that the reporter is closing.
	OnReporterClosing()
}

DataSink collects and sends data to a target.

type DataSinkRegisterer

type DataSinkRegisterer interface {
	Register(dataSink DataSink) error
	Deregister(dataSink DataSink)
}

DataSinkRegisterer is for registering DataSink

type DefaultDataSinkRegisterer

type DefaultDataSinkRegisterer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DefaultDataSinkRegisterer implements DataSinkRegisterer.

func NewDefaultDataSinkRegisterer

func NewDefaultDataSinkRegisterer(ctx context.Context) DefaultDataSinkRegisterer

NewDefaultDataSinkRegisterer creates a new DefaultDataSinkRegisterer which implements DataSinkRegisterer.

func (*DefaultDataSinkRegisterer) Deregister

func (r *DefaultDataSinkRegisterer) Deregister(dataSink DataSink)

Deregister implements DataSinkRegisterer.

func (*DefaultDataSinkRegisterer) Register

func (r *DefaultDataSinkRegisterer) Register(dataSink DataSink) error

Register implements DataSinkRegisterer.

type RemoteTopSQLReporter

type RemoteTopSQLReporter struct {
	DefaultDataSinkRegisterer
	// contains filtered or unexported fields
}

RemoteTopSQLReporter implements TopSQLReporter that sends data to a remote agent. This should be called periodically to collect TopSQL resource usage metrics.

func NewRemoteTopSQLReporter

func NewRemoteTopSQLReporter(decodePlan planBinaryDecodeFunc, compressPlan planBinaryCompressFunc) *RemoteTopSQLReporter

NewRemoteTopSQLReporter creates a new RemoteTopSQLReporter.

decodePlan is a decoding function which will be called asynchronously to decode the plan binary to string.

func (*RemoteTopSQLReporter) BindProcessCPUTimeUpdater

func (tsr *RemoteTopSQLReporter) BindProcessCPUTimeUpdater(updater collector.ProcessCPUTimeUpdater)

BindProcessCPUTimeUpdater implements TopSQLReporter.

func (*RemoteTopSQLReporter) Close

func (tsr *RemoteTopSQLReporter) Close()

Close implements TopSQLReporter.

func (*RemoteTopSQLReporter) Collect

func (tsr *RemoteTopSQLReporter) Collect(data []collector.SQLCPUTimeRecord)

Collect implements tracecpu.Collector.

WARN: It will drop the DataRecords if the processing is not in time. This function is thread-safe and efficient.

func (*RemoteTopSQLReporter) CollectStmtStatsMap

func (tsr *RemoteTopSQLReporter) CollectStmtStatsMap(data stmtstats.StatementStatsMap)

CollectStmtStatsMap implements stmtstats.Collector.

WARN: It will drop the DataRecords if the processing is not in time. This function is thread-safe and efficient.

func (*RemoteTopSQLReporter) RegisterPlan

func (tsr *RemoteTopSQLReporter) RegisterPlan(planDigest []byte, normalizedPlan string, isLarge bool)

RegisterPlan implements TopSQLReporter.

This function is thread-safe and efficient.

func (*RemoteTopSQLReporter) RegisterSQL

func (tsr *RemoteTopSQLReporter) RegisterSQL(sqlDigest []byte, normalizedSQL string, isInternal bool)

RegisterSQL implements TopSQLReporter.

This function is thread-safe and efficient.

func (*RemoteTopSQLReporter) Start

func (tsr *RemoteTopSQLReporter) Start()

Start implements the TopSQLReporter interface.

type ReportData

type ReportData struct {
	// DataRecords contains the topN records of each second and the `others`
	// record which aggregation all []tipb.TopSQLRecord that is out of Top N.
	DataRecords []tipb.TopSQLRecord
	SQLMetas    []tipb.SQLMeta
	PlanMetas   []tipb.PlanMeta
}

ReportData contains data that reporter sends to the agent.

type SingleTargetDataSink

type SingleTargetDataSink struct {
	// contains filtered or unexported fields
}

SingleTargetDataSink reports data to grpc servers.

func NewSingleTargetDataSink

func NewSingleTargetDataSink(registerer DataSinkRegisterer) *SingleTargetDataSink

NewSingleTargetDataSink returns a new SingleTargetDataSink

func (*SingleTargetDataSink) Close

func (ds *SingleTargetDataSink) Close()

Close uses to close grpc connection.

func (*SingleTargetDataSink) OnReporterClosing

func (ds *SingleTargetDataSink) OnReporterClosing()

OnReporterClosing implements the DataSink interface.

func (*SingleTargetDataSink) Start

func (ds *SingleTargetDataSink) Start()

Start starts to run SingleTargetDataSink.

func (*SingleTargetDataSink) TrySend

func (ds *SingleTargetDataSink) TrySend(data *ReportData, deadline time.Time) error

TrySend implements the DataSink interface. Currently the implementation will establish a new connection every time, which is suitable for a per-minute sending period

type TopSQLPubSubService

type TopSQLPubSubService struct {
	// contains filtered or unexported fields
}

TopSQLPubSubService implements tipb.TopSQLPubSubServer.

If a client subscribes to TopSQL records, the TopSQLPubSubService is responsible for registering an associated DataSink to the reporter. Then the DataSink sends data to the client periodically.

func NewTopSQLPubSubService

func NewTopSQLPubSubService(dataSinkRegisterer DataSinkRegisterer) *TopSQLPubSubService

NewTopSQLPubSubService creates a new TopSQLPubSubService.

func (*TopSQLPubSubService) Subscribe

func (ps *TopSQLPubSubService) Subscribe(_ *tipb.TopSQLSubRequest, stream tipb.TopSQLPubSub_SubscribeServer) error

Subscribe registers dataSinks to the reporter and redirects data received from reporter to subscribers associated with those dataSinks.

type TopSQLReporter

type TopSQLReporter interface {
	collector.Collector
	stmtstats.Collector

	// Start uses to start the reporter.
	Start()

	// RegisterSQL registers a normalizedSQL with SQLDigest.
	//
	// Note that the normalized SQL string can be of >1M long.
	// This function should be thread-safe, which means concurrently calling it
	// in several goroutines should be fine. It should also return immediately,
	// and do any CPU-intensive job asynchronously.
	RegisterSQL(sqlDigest []byte, normalizedSQL string, isInternal bool)

	// RegisterPlan like RegisterSQL, but for normalized plan strings.
	// isLarge indicates the size of normalizedPlan is big.
	RegisterPlan(planDigest []byte, normalizedPlan string, isLarge bool)

	// BindProcessCPUTimeUpdater is used to pass ProcessCPUTimeUpdater
	BindProcessCPUTimeUpdater(updater collector.ProcessCPUTimeUpdater)

	// Close uses to close and release the reporter resource.
	Close()
}

TopSQLReporter collects Top SQL metrics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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