mometric

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoggerName              = "MetricTask"
	LoggerNameMetricStorage = "MetricStorage"

	StorageUsageCronTask     = "StorageUsage"
	StorageUsageTaskCronExpr = ExprEvery05Min

	ExprEvery05Min = "0 */1 * * * *"
	ParamSeparator = " "
)
View Source
const (
	ShowAllAccountSQL = "SHOW ACCOUNTS;"
	ShowAccountSQL    = "SHOW ACCOUNTS like %q;"
	ColumnAccountName = "account_name" // result column in `show accounts`, or column in table mo_catalog.mo_account
	ColumnSize        = "size"         // result column in `show accounts`, or column in table mo_catalog.mo_account
	ColumnCreatedTime = "created_time" // column in table mo_catalog.mo_account
	ColumnStatus      = "status"       // column in table mo_catalog.mo_account
)
View Source
const (
	MetricDBConst    = metric.MetricDBConst
	SqlCreateDBConst = "create database if not exists " + MetricDBConst
	SqlDropDBConst   = "drop database if exists " + MetricDBConst
	ALL_IN_ONE_MODE  = "monolithic"
)
View Source
const CHAN_CAPACITY = 10000
View Source
const LaunchMode = "ALL"

Variables

View Source
var SingleMetricTable = &table.Table{
	Account:          table.AccountSys,
	Database:         MetricDBConst,
	Table:            `metric`,
	Columns:          []table.Column{metricNameColumn, metricCollectTimeColumn, metricValueColumn, metricNodeColumn, metricRoleColumn, metricAccountColumn, metricTypeColumn},
	PrimaryKeyColumn: []table.Column{},
	ClusterBy:        []table.Column{metricCollectTimeColumn, metricNameColumn, metricAccountColumn},
	Engine:           table.NormalTableEngine,
	Comment:          `metric data`,
	PathBuilder:      table.NewAccountDatePathBuilder(),
	AccountColumn:    &metricAccountColumn,

	TimestampColumn: &metricCollectTimeColumn,

	SupportUserAccess: true,

	SupportConstAccess: true,
}
View Source
var SqlStatementCUTable = &table.Table{
	Account:          table.AccountSys,
	Database:         MetricDBConst,
	Table:            catalog.MO_SQL_STMT_CU,
	Columns:          []table.Column{metricAccountColumn, metricCollectTimeColumn, metricValueColumn, metricNodeColumn, metricRoleColumn, sqlSourceTypeColumn},
	PrimaryKeyColumn: []table.Column{},
	ClusterBy:        []table.Column{metricAccountColumn, metricCollectTimeColumn},
	Engine:           table.NormalTableEngine,
	Comment:          `sql_statement_cu metric data`,
	PathBuilder:      table.NewAccountDatePathBuilder(),
	AccountColumn:    &metricAccountColumn,

	TimestampColumn: &metricCollectTimeColumn,

	SupportUserAccess: true,

	SupportConstAccess: true,
}

Functions

func CalculateStorageUsage added in v1.0.0

func CalculateStorageUsage(ctx context.Context, sqlExecutor func() ie.InternalExecutor) (err error)

func CreateCronTask added in v1.0.0

func CreateCronTask(ctx context.Context, executorID task.TaskCode, taskService taskservice.TaskService) error

CreateCronTask should init once in/with schema-init.

func GetAllTables deprecated added in v1.0.0

func GetAllTables() []*table.Table

GetAllTables

Deprecated: use table.GetAllTables() instead.

func GetMetricStorageUsageExecutor added in v1.0.0

func GetMetricStorageUsageExecutor(sqlExecutor func() ie.InternalExecutor) func(ctx context.Context, task task.Task) error

GetMetricStorageUsageExecutor collect metric server_storage_usage

func GetMetricViewWithLabels

func GetMetricViewWithLabels(ctx context.Context, tbl string, lbls []string) *table.View

func GetSchemaForAccount

func GetSchemaForAccount(ctx context.Context, account string) []string

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

func GetStorageUsageCheckNewInterval added in v1.0.0

func GetStorageUsageCheckNewInterval() time.Duration

func GetUpdateStorageUsageInterval added in v1.0.0

func GetUpdateStorageUsageInterval() time.Duration

func InitMetric

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

func InitSchema

func InitSchema(ctx context.Context, txn executor.TxnExecutor) error

func IsEnable added in v1.0.0

func IsEnable() bool

func NewMetricView

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

func NewMetricViewWithLabels

func NewMetricViewWithLabels(ctx context.Context, tbl string, lbls []string) *table.View

func SetStorageUsageCheckNewInterval added in v1.0.0

func SetStorageUsageCheckNewInterval(interval time.Duration)

func SetUpdateStorageUsageInterval added in v1.0.0

func SetUpdateStorageUsageInterval(interval time.Duration)

func StopMetricSync

func StopMetricSync()

func TaskMetadata added in v1.0.0

func TaskMetadata(jobName string, id task.TaskCode, args ...string) task.TaskMetadata

TaskMetadata handle args like: "{db_tbl_name} [date, default: today]"

Types

type CtxServiceType added in v1.0.0

type CtxServiceType string
const ServiceTypeKey CtxServiceType = "ServiceTypeKey"

type ExporterOption added in v1.0.0

type ExporterOption func(*metricExporter)

func WithGatherInterval added in v1.0.0

func WithGatherInterval(interval time.Duration) ExporterOption

type InitOption

type InitOption func(*InitOptions)

func WithInitAction deprecated

func WithInitAction(init bool) InitOption

Deprecated: Use InitSchema instead.

func WithInternalGatherInterval added in v1.0.0

func WithInternalGatherInterval(interval time.Duration) InitOption

func WithWriterFactory

func WithWriterFactory(factory table.WriterFactory) InitOption

func (InitOption) ApplyTo

func (f InitOption) ApplyTo(opts *InitOptions)

type InitOptions

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 StatsLogWriter

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

func (*StatsLogWriter) Start

func (e *StatsLogWriter) Start(inputCtx context.Context) bool

func (*StatsLogWriter) Stop

func (e *StatsLogWriter) Stop(_ bool) (<-chan struct{}, 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