metric

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricDBConst = "system_metrics"

	ALL_IN_ONE_MODE = "monolithic"
)
View Source
const CHAN_CAPACITY = 10000

Variables

View Source
var (
	StatementCounterFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "statement_total",
			Help:      "Counter of executed sql statement",
		},
		[]string{constTenantKey, "type"},
		false,
	)

	TransactionCounterFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "transaction_total",
			Help:      "Counter of transaction",
		},
		[]string{constTenantKey},
		false,
	)

	TransactionErrorsFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "transaction_errors",
			Help:      "Counter of errors on execute commit/rollback statement",
		},
		[]string{constTenantKey, "type"},
		false,
	)

	StatementErrorsFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "statement_errors",
			Help:      "Counter of executed sql statement failed.",
		},
		[]string{constTenantKey, "type"},
		false,
	)
)
View Source
var (
	ConnFactory = NewGaugeVec(
		GaugeOpts{
			Subsystem: "server",
			Name:      "connections",
			Help:      "Number of process connections",
		},
		[]string{constTenantKey},
	)
)
View Source
var SingleMetricTable = &export.Table{
	Account:          export.AccountAll,
	Database:         MetricDBConst,
	Table:            `metric`,
	Columns:          []export.Column{metricNameColumn, metricCollectTimeColumn, metricValueColumn, metricNodeColumn, metricRoleColumn, metricAccountColumn, metricTypeColumn},
	PrimaryKeyColumn: []export.Column{},
	Engine:           export.ExternalTableEngine,
	Comment:          `metric data`,
	PathBuilder:      export.NewAccountDatePathBuilder(),
	AccountColumn:    &metricAccountColumn,

	SupportUserAccess: true,
}
View Source
var SubSystemProcess = &SubSystem{"process", "MO process status", false}
View Source
var SubSystemServer = &SubSystem{"server", "MO Server status, observe from inside", true}
View Source
var SubSystemSql = &SubSystem{"sql", "base on query action", true}
View Source
var SubSystemSys = &SubSystem{"sys", "OS status", false}

Functions

func ExponentialBuckets

func ExponentialBuckets(start, factor float64, count int) []float64

ExponentialBuckets produces list like `[start, start * factor, start * factor^2, ..., start * factor^(count-1)]`

func GetMetricViewWithLabels added in v0.6.0

func GetMetricViewWithLabels(tbl string, lbls []string) *export.View

func GetSchemaForAccount added in v0.6.0

func GetSchemaForAccount(account string) []string

GetSchemaForAccount return account's table, and view's schema

func InitMetric

func InitMetric(ctx context.Context, ieFactory func() ie.InternalExecutor, SV *config.ObservabilityParameters, nodeUUID, role string, opts ...InitOption)

func InitSchema added in v0.6.0

func InitSchema(ctx context.Context, ieFactory func() ie.InternalExecutor) error

func NewCounter

func NewCounter(opts prom.CounterOpts) *ratecounter

func NewCounterVec

func NewCounterVec(opts CounterOpts, lvs []string, doAvg bool) *rateCounterVec

func NewGauge

func NewGauge(opts prom.GaugeOpts) *gauge

func NewGaugeVec

func NewGaugeVec(opts prom.GaugeOpts, lvs []string) *gaugeVec

func NewMetricView added in v0.6.0

func NewMetricView(tbl string, opts ...export.ViewOption) *export.View

func NewMetricViewWithLabels added in v0.6.0

func NewMetricViewWithLabels(tbl string, lbls []string) *export.View

func NewRawHist

func NewRawHist(opts prom.HistogramOpts) *rawHist

func StopMetricSync

func StopMetricSync()

Types

type Collector

type Collector interface {
	prom.Collector
	// cancelToProm remove the cost introduced by being compatible with prometheus
	CancelToProm()
	// collectorForProm returns a collector used in prometheus scrape registry
	CollectorToProm() prom.Collector
}

type Counter

type Counter interface {
	prom.Counter
}

func StatementCounter

func StatementCounter(tenant string, t SQLType) Counter

func StatementErrorsCounter added in v0.6.0

func StatementErrorsCounter(account string, t SQLType) Counter

func TransactionCounter added in v0.6.0

func TransactionCounter(tenant string) Counter

func TransactionErrorsCounter added in v0.6.0

func TransactionErrorsCounter(account string, t SQLType) Counter

type CounterOpts

type CounterOpts = prom.CounterOpts

type ExportMultiTable added in v0.6.0

type ExportMultiTable bool

func (ExportMultiTable) ApplyTo added in v0.6.0

func (x ExportMultiTable) ApplyTo(o *collectorOpts)

type Gauge

type Gauge interface {
	prom.Gauge
}

func ConnectionCounter added in v0.6.0

func ConnectionCounter(account string) Gauge

type GaugeOpts

type GaugeOpts = prom.GaugeOpts

type HistogramOpts

type HistogramOpts = prom.HistogramOpts

type InitOption added in v0.6.0

type InitOption func(*InitOptions)

func WithExportInterval added in v0.6.0

func WithExportInterval(sec int) InitOption

func WithInitAction added in v0.6.0

func WithInitAction(init bool) InitOption

func WithMultiTable added in v0.6.0

func WithMultiTable(multi bool) InitOption

func WithWriterFactory added in v0.6.0

func WithWriterFactory(factory export.FSWriterFactory) InitOption

func (InitOption) ApplyTo added in v0.6.0

func (f InitOption) ApplyTo(opts *InitOptions)

type InitOptions added in v0.6.0

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

type MetricCollector

type MetricCollector interface {
	SendMetrics(context.Context, []*pb.MetricFamily) error
	Start(context.Context) bool
	Stop(graceful bool) (<-chan struct{}, bool)
}

type MetricExporter

type MetricExporter interface {
	// ExportMetricFamily can be used by a metric to push data. this method must be thread safe
	ExportMetricFamily(context.Context, *pb.MetricFamily) error
	Start(context.Context) bool
	Stop(bool) (<-chan struct{}, bool)
}

type Observer

type Observer interface {
	prom.Observer
}

type RawHistVec

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

RawHistVec is a Collector that bundles a set of RawHist that all share the same Desc, but have different values for their variable labels. It can be used as a factory for a series of Observers

func NewRawHistVec

func NewRawHistVec(opts prom.HistogramOpts, labelNames []string) *RawHistVec

NewRawHistVec creates a new NewRawHistVec based on the provided HistogramOpts and partitioned by the given label names.

func (*RawHistVec) CancelToProm

func (v *RawHistVec) CancelToProm()

func (*RawHistVec) Collect

func (v *RawHistVec) Collect(ch chan<- prom.Metric)

func (*RawHistVec) CollectorToProm

func (v *RawHistVec) CollectorToProm() prom.Collector

func (*RawHistVec) Describe

func (v *RawHistVec) Describe(ch chan<- *prom.Desc)

func (*RawHistVec) GetMetricWithLabelValues

func (v *RawHistVec) GetMetricWithLabelValues(lvs ...string) (Observer, error)

func (*RawHistVec) WithLabelValues

func (v *RawHistVec) WithLabelValues(lvs ...string) prom.Observer

type SQLType

type SQLType string
var (
	SQLTypeSelect SQLType = "select"
	SQLTypeInsert SQLType = "insert"
	SQLTypeUpdate SQLType = "update"
	SQLTypeDelete SQLType = "delete"
	SQLTypeOther  SQLType = "other"

	SQLTypeBegin        SQLType = "begin"
	SQLTypeCommit       SQLType = "commit"
	SQLTypeRollback     SQLType = "rollback"
	SQLTypeAutoCommit   SQLType = "auto_commit"
	SQLTypeAutoRollback SQLType = "auto_rollback"
)

type SubSystem added in v0.6.0

type SubSystem struct {
	Name              string
	Comment           string
	SupportUserAccess bool
}

type WithFlushInterval

type WithFlushInterval time.Duration

func (WithFlushInterval) ApplyTo

func (x WithFlushInterval) ApplyTo(o *collectorOpts)

type WithMetricThreshold

type WithMetricThreshold int

func (WithMetricThreshold) ApplyTo

func (x WithMetricThreshold) ApplyTo(o *collectorOpts)

type WithSampleThreshold

type WithSampleThreshold int

func (WithSampleThreshold) ApplyTo

func (x WithSampleThreshold) ApplyTo(o *collectorOpts)

type WithSqlWorkerNum

type WithSqlWorkerNum int

func (WithSqlWorkerNum) ApplyTo

func (x WithSqlWorkerNum) ApplyTo(o *collectorOpts)

Jump to

Keyboard shortcuts

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