metrics

package
v0.0.0-...-89d789c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendEventIniting = "initing"
	BackendEventInited  = "inited"
	BackendEventClosing = "closing"
	BackendEventClosed  = "closed"
)
View Source
const (
	LabelServer    = "server"
	LabelQueryCtx  = "queryctx"
	LabelBackend   = "backend"
	LabelSession   = "session"
	LabelDomain    = "domain"
	LabelDDLOwner  = "ddl-owner"
	LabelDDL       = "ddl"
	LabelDDLWorker = "ddl-worker"
	LabelDDLSyncer = "ddl-syncer"
	LabelGCWorker  = "gcworker"
	LabelAnalyze   = "analyze"

	LabelBatchRecvLoop = "batch-recv-loop"
	LabelBatchSendLoop = "batch-send-loop"

	LableScope   = "scope"
	ScopeGlobal  = "global"
	ScopeSession = "session"
)

metrics labels.

View Source
const (
	StmtNameUnknown  = "unknown"
	StmtNameSelect   = "select"
	StmtNameInsert   = "insert"
	StmtNameUpdate   = "update"
	StmtNameDelete   = "delete"
	StmtNameDDL      = "ddl"
	StmtNameBegin    = "begin"
	StmtNameCommit   = "commit"
	StmtNameRollback = "rollback"
	StmtNameSet      = "set"
	StmtNameShow     = "show"
	StmtNameUse      = "use"
	StmtNameComment  = "comment"
)
View Source
const (
	LblUnretryable = "unretryable"
	LblReachMax    = "reach_max"
	LblOK          = "ok"
	LblError       = "error"
	LblCommit      = "commit"
	LblAbort       = "abort"
	LblRollback    = "rollback"
	LblType        = "type"
	LblDb          = "db"
	LblTable       = "table"
	LblResult      = "result"
	LblSQLType     = "sql_type"
	LblGeneral     = "general"
	LblInternal    = "internal"
	LbTxnMode      = "txn_mode"
	LblPessimistic = "pessimistic"
	LblOptimistic  = "optimistic"
	LblStore       = "store"
	LblAddress     = "address"
	LblBatchGet    = "batch_get"
	LblGet         = "get"
	LblNamespace   = "namespace"
	LblCluster     = "cluster"

	LblBackendAddr = "backend_addr"
)

Label constants.

View Source
const (
	ModuleWeirProxy = "weirproxy"
)

Variables

View Source
var (
	BackendEventCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelBackend,
			Name:      "backend_event_total",
			Help:      "Counter of backend event.",
		}, []string{LblCluster, LblNamespace, LblType})

	BackendQueryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelBackend,
			Name:      "b_conn_cnt",
			Help:      "Counter of backend query count.",
		}, []string{LblCluster, LblNamespace, LblBackendAddr})

	BackendConnInUseGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelBackend,
			Name:      "b_conn_in_use",
			Help:      "Number of backend conn in use.",
		}, []string{LblCluster, LblNamespace, LblBackendAddr})
)
View Source
var (
	QueryCtxQueryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelQueryCtx,
			Name:      "query_total",
			Help:      "Counter of queries.",
		}, []string{LblCluster, LblNamespace, LblDb, LblTable, LblSQLType, LblResult})

	QueryCtxQueryDeniedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelQueryCtx,
			Name:      "query_denied",
			Help:      "Counter of denied queries.",
		}, []string{LblCluster, LblNamespace, LblDb, LblTable, LblSQLType})

	QueryCtxQueryDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelQueryCtx,
			Name:      "handle_query_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handled queries.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblCluster, LblNamespace, LblDb, LblTable, LblSQLType})

	QueryCtxGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelQueryCtx,
			Name:      "queryctx",
			Help:      "Number of queryctx (equals to client connection).",
		}, []string{LblCluster, LblNamespace})

	QueryCtxAttachedConnGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelQueryCtx,
			Name:      "attached_connections",
			Help:      "Number of attached backend connections.",
		}, []string{LblCluster, LblNamespace})

	QueryCtxTransactionDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "transaction_duration_seconds",
			Help:      "Bucketed histogram of a transaction execution duration, including retry.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblCluster, LblNamespace, LblDb, LblSQLType})
)
View Source
var (
	// PanicCounter measures the count of panics.
	PanicCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelServer,
			Name:      "panic_total",
			Help:      "Counter of panic.",
		}, []string{LblCluster, LblType})

	QueryTotalCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelServer,
			Name:      "query_total",
			Help:      "Counter of queries.",
		}, []string{LblCluster, LblType, LblResult})

	ExecuteErrorCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelServer,
			Name:      "execute_error_total",
			Help:      "Counter of execute errors.",
		}, []string{LblCluster, LblType})

	ConnGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleWeirProxy,
			Subsystem: LabelServer,
			Name:      "connections",
			Help:      "Number of connections.",
		}, []string{LblCluster})

	EventStart        = "start"
	EventGracefulDown = "graceful_shutdown"
	// Eventkill occurs when the server.Kill() function is called.
	EventKill  = "kill"
	EventClose = "close"
)

Functions

func ExecuteErrorToLabel

func ExecuteErrorToLabel(err error) string

ExecuteErrorToLabel converts an execute error to label.

func GetStmtTypeName

func GetStmtTypeName(stmt ast.StmtNode) string

func RegisterProxyMetrics

func RegisterProxyMetrics(cluster string)

func RetLabel

func RetLabel(err error) string

RetLabel returns "ok" when err == nil and "err" when err != nil. This could be useful when you need to observe the operation result.

Types

type AstStmtType

type AstStmtType int
const (
	StmtTypeUnknown AstStmtType = iota
	StmtTypeSelect
	StmtTypeInsert
	StmtTypeUpdate
	StmtTypeDelete
	StmtTypeDDL
	StmtTypeBegin
	StmtTypeCommit
	StmtTypeRollback
	StmtTypeSet
	StmtTypeShow
	StmtTypeUse
	StmtTypeComment
)

func GetStmtType

func GetStmtType(stmt ast.StmtNode) AstStmtType

Jump to

Keyboard shortcuts

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