qan

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2016 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_COLLECT_FROM              = "slowlog"
	DEFAULT_INTERVAL                  = 60         // 1 minute
	DEFAULT_LONG_QUERY_TIME           = 0.001      // 1ms
	DEFAULT_MAX_SLOW_LOG_SIZE         = 1073741824 // 1G
	DEFAULT_REMOVE_OLD_SLOW_LOGS      = true
	DEFAULT_EXAMPLE_QUERIES           = true
	DEFAULT_SLOW_LOG_VERBOSITY        = "full" // all metrics, Percona Server
	DEFAULT_RATE_LIMIT                = 100    // 1%, Percona Server
	DEFAULT_LOG_SLOW_ADMIN_STATEMENTS = true   // Percona Server
	DEFAULT_LOG_SLOW_SLAVE_STATEMENTS = true   // Percona Server
	// internal
	DEFAULT_WORKER_RUNTIME = 55
	DEFAULT_REPORT_LIMIT   = 200
)
View Source
const MIN_SLOWLOG_ROTATION_SIZE = 4096

Variables

View Source
var (
	ErrNotRunning     = errors.New("not running")
	ErrAlreadyRunning = errors.New("already running")
)

Functions

func GetMySQLConfig

func GetMySQLConfig(config pc.QAN, distro, version string) ([]string, []string, error)

func MakeReport

func MakeReport(config pc.QAN, interval *Interval, result *Result) *qan.Report

func ValidateConfig

func ValidateConfig(setConfig map[string]string) (pc.QAN, error)

Types

type Analyzer

type Analyzer interface {
	Start() error
	Stop() error
	Status() map[string]string
	String() string
	Config() pc.QAN
	SetConfig(pc.QAN)
}

An Analyzer runs a Worker at each Interval. Analyzers are responsible for MySQL: configuring, restarts, etc. The Worker is only ran when MySQL is configured and ready. Analyzers are also responsible for making Reports from the Results returned by Workers. The Worker determines the type of Analyzer: slowlog or perfschema. Analyzers are ran by the QAN Manager.

type AnalyzerFactory

type AnalyzerFactory interface {
	Make(config pc.QAN, name string, mysqlConn mysql.Connector, restartChan chan proto.Instance, tickChan chan time.Time) Analyzer
}

An AnalyzerFactory makes an Analyzer, real or mock.

type AnalyzerInstance

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

An AnalyzerInstnace is an Analyzer ran by a Manager, one per MySQL instance as configured.

type ByQueryTime

type ByQueryTime []*event.Class

func (ByQueryTime) Len

func (a ByQueryTime) Len() int

func (ByQueryTime) Less

func (a ByQueryTime) Less(i, j int) bool

func (ByQueryTime) Swap

func (a ByQueryTime) Swap(i, j int)

type Interval

type Interval struct {
	Number    int
	StartTime time.Time // UTC
	StopTime  time.Time // UTC
	// slowlog
	Filename    string // slow_query_log_file
	StartOffset int64  // bytes @ StartTime
	EndOffset   int64  // bytes @ StopTime
}

An Interval represents a period during which queries are fetched, aggregated, and reported. Intervals are created and sent by an IntervalIter. Analyzers use Intervals to set up and run Workers.

func (*Interval) String

func (i *Interval) String() string

type IntervalIter

type IntervalIter interface {
	Start()
	Stop()
	IntervalChan() chan *Interval
	TickChan() chan time.Time
}

An IntervalIter sends Intervals.

type IntervalIterFactory

type IntervalIterFactory interface {
	Make(analyzerType string, mysqlConn mysql.Connector, tickChan chan time.Time) IntervalIter
}

An IntervalIterFactory makes an IntervalIter, real or mock.

type Manager

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

A Manager runs AnalyzerInstances, one per MySQL instance as configured.

func NewManager

func NewManager(
	logger *pct.Logger,
	clock ticker.Manager,
	instanceRepo *instance.Repo,
	mrm mrms.Monitor,
	mysqlFactory mysql.ConnectionFactory,
	analyzerFactory AnalyzerFactory,
) *Manager

func (*Manager) GetConfig

func (m *Manager) GetConfig() ([]proto.AgentConfig, []error)

func (*Manager) GetDefaults

func (m *Manager) GetDefaults() map[string]interface{}

func (*Manager) Handle

func (m *Manager) Handle(cmd *proto.Cmd) *proto.Reply

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Status

func (m *Manager) Status() map[string]string

func (*Manager) Stop

func (m *Manager) Stop() error

type RealAnalyzer

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

func NewRealAnalyzer

func NewRealAnalyzer(logger *pct.Logger, config pc.QAN, iter IntervalIter, mysqlConn mysql.Connector, restartChan chan proto.Instance, worker Worker, clock ticker.Manager, spool data.Spooler) *RealAnalyzer

func (*RealAnalyzer) Config

func (a *RealAnalyzer) Config() pc.QAN

func (*RealAnalyzer) SetConfig

func (a *RealAnalyzer) SetConfig(config pc.QAN)

func (*RealAnalyzer) Start

func (a *RealAnalyzer) Start() error

func (*RealAnalyzer) Status

func (a *RealAnalyzer) Status() map[string]string

func (*RealAnalyzer) Stop

func (a *RealAnalyzer) Stop() error

func (*RealAnalyzer) String

func (a *RealAnalyzer) String() string

func (*RealAnalyzer) TakeOverPerconaServerRotation

func (a *RealAnalyzer) TakeOverPerconaServerRotation() error

Disable Percona Server slow log rotation and handle internally using the max_slowlog_size value. The slow log worker must rotate slow logs by itself to ensure full and proper parsing across rotations.

type Result

type Result struct {
	Global     *event.Class   // metrics for all data
	Class      []*event.Class // per-class metrics
	RateLimit  uint           // Percona Server rate limit
	RunTime    float64        // seconds parsing data, hopefully < interval
	StopOffset int64          // slow log offset where parsing stopped, should be <= end offset
	Error      string         `json:",omitempty"`
}

Data for an interval from slow log or performance schema (pfs) parser, passed to MakeReport() which transforms into a qan.Report{}.

type Worker

type Worker interface {
	Setup(*Interval) error
	Run() (*Result, error)
	Stop() error
	Cleanup() error
	Status() map[string]string
	SetConfig(pc.QAN)
}

A Worker gets queries, aggregates them, and returns a Result. Workers are ran by Analyzers. When ran, MySQL is presumed to be configured and ready.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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