metric

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubSystemSql is the subsystem which base on query action.
	SubSystemSql = "sql"
	// SubSystemServer is the subsystem which base on server status, trigger by client query.
	SubSystemServer = "server"
	// SubSystemProcess is the subsystem which base on process status.
	SubSystemProcess = "process"
	// SubSystemSys is the subsystem which base on OS status.
	SubSystemSys = "sys"
	// SubSystemMO is the subsystem which show mo internal status
	SubSystemMO = "mo"
)
View Source
const MetricDBConst = "system_metrics"

Variables

View Source
var (
	ConnFactory = NewGaugeVec(
		GaugeOpts{
			Subsystem: "server",
			Name:      "connections",
			Help:      "Number of process connections",
		},
		[]string{constTenantKey},
	)

	StorageUsageFactory = NewGaugeVec(
		GaugeOpts{
			Subsystem: "server",
			Name:      "storage_usage",
			Help:      "Storage usage of each account",
		},
		[]string{constTenantKey},
	)
)
View Source
var (
	StatementCounterFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "statement_total",
			Help:      "Counter of executed sql statement",
		},
		[]string{constTenantKey, "type"},
		false,
	)

	StatementDurationFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "statement_duration_total",
			Help:      "Statement duration of each query type for each account",
		},
		[]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,
	)

	StatementCUCounterFactory = NewCounterVec(
		CounterOpts{
			Subsystem: "sql",
			Name:      "statement_cu",
			Help:      "Counter of executed sql statement cu",
		},
		[]string{constTenantKey, "sql_source_type"},
		false,
	)
)
View Source
var (
	LblNodeConst  = "node"
	LblRoleConst  = "role"
	LblValueConst = "value"
	LblTimeConst  = "collecttime"
)
View Source
var AllSubSystem = map[string]*SubSystem{}

InitCollectors contains all the collectors that belong to SubSystemSql, SubSystemServer, SubSystemProcess and SubSystemStatement.

View Source
var InternalCollectors = []Collector{

	MOLogMessageFactory,
}

InternalCollectors contains all the collectors that belong to SubSystemMO

View Source
var (
	MOLogMessageFactory = NewCounterVec(
		CounterOpts{
			Subsystem: SubSystemMO,
			Name:      "log_message_count",
			Help:      "Count of log message",
		},
		[]string{constTenantKey, "type"},
		false,
	)
)

Functions

func EnableExportToProm added in v1.0.0

func EnableExportToProm() bool

func EnvOrDefaultBool added in v0.8.0

func EnvOrDefaultBool(key string, defaultValue int32) int32

func EnvOrDefaultInt added in v0.8.0

func EnvOrDefaultInt[T int32 | int64](key string, defaultValue T) T

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 GetForceInit added in v0.8.0

func GetForceInit() bool

func GetGatherInterval added in v0.8.0

func GetGatherInterval() time.Duration

func GetRawHistBufLimit added in v0.8.0

func GetRawHistBufLimit() int32

func GetStatsGatherInterval added in v0.8.0

func GetStatsGatherInterval() time.Duration

func IsFullBatchRawHist added in v0.8.0

func IsFullBatchRawHist(mf *pb.MetricFamily) bool

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 NewRawHist

func NewRawHist(opts prom.HistogramOpts) *rawHist

func RegisterSubSystem added in v0.8.0

func RegisterSubSystem(s *SubSystem)

func SetExportToProm added in v0.8.0

func SetExportToProm(new bool) bool

func SetGatherInterval added in v0.8.0

func SetGatherInterval(new time.Duration) time.Duration

func SetMetricExporter added in v0.8.0

func SetMetricExporter(e MetricExporter)

func SetRawHistBufLimit added in v0.8.0

func SetRawHistBufLimit(new int32) int32

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 MOLogMessageCounter added in v1.0.0

func MOLogMessageCounter(level string) Counter

func StatementCUCounter added in v1.1.2

func StatementCUCounter(account string, sqlSourceType string) Counter

StatementCUCounter accept @account, @sqlSourceType @account is the account name of the user who executes the sql statement. @sqlSourceType is the type of sql source, such as InternalSql, CloudNoUserSql, ExternalSql, CloudUserSql etc.

func StatementCounter

func StatementCounter(tenant string, t string) Counter

StatementCounter accept t as tree.QueryType

func StatementDuration added in v1.1.2

func StatementDuration(tenant string, t string) Counter

func StatementErrorsCounter added in v0.6.0

func StatementErrorsCounter(account string, t string) Counter

StatementErrorsCounter accept t as tree.QueryType

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 ExporterHolder added in v0.8.0

type ExporterHolder struct {
	atomic.Value
}

func NewExportHolder added in v0.8.0

func NewExportHolder(e MetricExporter) *ExporterHolder

func (*ExporterHolder) Get added in v0.8.0

func (h *ExporterHolder) Get() MetricExporter

type Gauge

type Gauge interface {
	prom.Gauge
}

func ConnectionCounter added in v0.6.0

func ConnectionCounter(account string) Gauge

func StorageUsage added in v0.7.0

func StorageUsage(account string) Gauge

type GaugeOpts

type GaugeOpts = prom.GaugeOpts

type HistogramOpts

type HistogramOpts = prom.HistogramOpts

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
}

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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