metric

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheKey_MemStats cacheKey = iota
	CacheKey_Process
)
View Source
const (
	METRIC_DB       = "system_metrics"
	SQL_CREATE_DB   = "create database if not exists " + METRIC_DB
	SQL_DROP_DB     = "drop database if exists " + METRIC_DB
	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{"type", "internal"},
	)

	SQLLatencyObserverFactory = NewRawHistVec(
		HistogramOpts{
			Subsystem: "sql",
			Name:      "latency_seconds",
			Help:      "Processing time in seconds of handled sql statement",

			Buckets: ExponentialBuckets(0.0005, 2, 28),
		},
		[]string{"type", "internal"},
	)
)
View Source
var (
	LBL_NODE  = "node"
	LBL_ROLE  = "role"
	LBL_VALUE = "value"
	LBL_TIME  = "collecttime"
)
View Source
var HardwareStatsCollector = newBatchStatsCollector(
	cpuTotal{},
	cpuPercent{},
	memUsed{},
	memAvail{},
)
View Source
var ProcessCollector = newBatchStatsCollector(procCpuPercent{}, procMemUsage{}, procOpenFds{}, procFdsLimit{})

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 InitMetric

func InitMetric(ieFactory func() ie.InternalExecutor, pu *config.ParameterUnit, nodeId int, role string)

func NewCounter

func NewCounter(opts prom.CounterOpts) *ratecounter

func NewCounterVec

func NewCounterVec(opts CounterOpts, lvs []string) *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 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(t SQLType, isInternal bool) Counter

type CounterOpts

type CounterOpts = prom.CounterOpts

type Gauge

type Gauge interface {
	prom.Gauge
}

type GaugeOpts

type GaugeOpts = prom.GaugeOpts

type HistogramOpts

type HistogramOpts = prom.HistogramOpts

type MetricCollector

type MetricCollector interface {
	SendMetrics(context.Context, []*pb.MetricFamily) error
	Start()
	Stop() (<-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()
	Stop() (<-chan struct{}, bool)
}

type Observer

type Observer interface {
	prom.Observer
}

func SQLLatencyObserver

func SQLLatencyObserver(t SQLType, isInternal bool) 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 (r *RawHistVec) CancelToProm()

func (*RawHistVec) Collect

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

func (*RawHistVec) CollectorToProm

func (r *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 int
const (
	SQLTypeSelect SQLType = iota
	SQLTypeInsert
	SQLTypeUpdate
	SQLTypeDelete
	SQLTypeOther
)

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