Documentation ¶
Index ¶
- Constants
- Variables
- func GetMySQLConfig(config pc.QAN, distro, version string) ([]string, []string, error)
- func MakeReport(config pc.QAN, interval *Interval, result *Result) *qan.Report
- func ValidateConfig(setConfig map[string]string) (pc.QAN, error)
- type Analyzer
- type AnalyzerFactory
- type AnalyzerInstance
- type ByQueryTime
- type Interval
- type IntervalIter
- type IntervalIterFactory
- type Manager
- type RealAnalyzer
- func (a *RealAnalyzer) Config() pc.QAN
- func (a *RealAnalyzer) SetConfig(config pc.QAN)
- func (a *RealAnalyzer) Start() error
- func (a *RealAnalyzer) Status() map[string]string
- func (a *RealAnalyzer) Stop() error
- func (a *RealAnalyzer) String() string
- func (a *RealAnalyzer) TakeOverPerconaServerRotation() error
- type Result
- type Worker
Constants ¶
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 )
const MIN_SLOWLOG_ROTATION_SIZE = 4096
Variables ¶
var ( ErrNotRunning = errors.New("not running") ErrAlreadyRunning = errors.New("already running") )
Functions ¶
func GetMySQLConfig ¶
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 ¶
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.
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 (*Manager) GetDefaults ¶
type RealAnalyzer ¶
type RealAnalyzer struct {
// contains filtered or unexported fields
}
func NewRealAnalyzer ¶
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.