metrics

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultGRPCServerMetrics defines default gRPC server metrics
	DefaultGRPCServerMetrics = openmetrics.NewServerMetrics(openmetrics.WithServerHandlingTimeHistogram())
	// DefaultGRPCClientMetrics defines default gRPC client metrics
	DefaultGRPCClientMetrics = openmetrics.NewClientMetrics(openmetrics.WithClientHandlingTimeHistogram(),
		openmetrics.WithClientStreamSendHistogram(), openmetrics.WithClientStreamRecvHistogram())
	// DefaultHTTPServerMetrics defines default HTTP server metrics
	DefaultHTTPServerMetrics = metricshttp.NewServerMetrics()

	// GolangRuntimeMetrics defines some runtime metrics about golang
	GolangRuntimeMetrics = collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(
		collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}))
	// ProcessMetrics defines some metrics about current sp process
	ProcessMetrics = collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})

	// task queue metrics
	QueueSizeGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "queue_size",
		Help: "Track the task queue used size.",
	}, []string{"queue_size"})
	QueueCapGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "queue_capacity",
		Help: "Track the task queue capacity.",
	}, []string{"queue_capacity"})
	QueueTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "queue_time",
		Help:    "Track the task of queue operator time.",
		Buckets: prometheus.DefBuckets,
	}, []string{"queue_time"})
	TaskInQueueTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "task_in_queue_time",
		Help:    "Track the task of alive time duration in queue from task is pushed.",
		Buckets: prometheus.DefBuckets,
	}, []string{"task_in_queue_time"})

	// piece store metrics
	PieceStoreTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "piece_store_time",
		Help:    "Track the time of operating piece store.",
		Buckets: prometheus.DefBuckets,
	}, []string{"piece_store_time"})
	PieceStoreCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "piece_store_counter",
		Help: "Track total counter of operating piece store.",
	}, []string{"piece_store_counter"})
	PieceStoreUsageAmountGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "usage_amount_piece_store",
		Help: "Track usage amount of piece store.",
	}, []string{"usage_amount_piece_store"})

	// spdb metrics
	SPDBTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "sp_db_time",
		Help:    "Track the time of operating spdb",
		Buckets: prometheus.DefBuckets,
	}, []string{"sp_db_time"})
	SPDBCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "sp_db_counter",
		Help: "Track total counter of operating spdb.",
	}, []string{"sp_db_counter"})

	GnfdChainTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "gnfd_chain_time",
		Help:    "Track the time of greenfield chain api costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"gnfd_chain_time"})
	GnfdChainCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "gnfd_chain_counter",
		Help: "Track the counter of greenfield chain api.",
	}, []string{"gnfd_chain_counter"})
	BlockHeightLagGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "block_syncer_height",
		Help: "Current block number of block syncer progress.",
	}, []string{"block_syncer_height"})
)

basic metrics items

View Source
var (
	// common module metrics items
	ReqCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "request_qps",
		Help: "Track total request counter.",
	}, []string{"request_qps"})
	ReqTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "request_time",
		Help:    "Track the request time.",
		Buckets: prometheus.DefBuckets,
	}, []string{"request_time"})
	ReqPieceSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "request_piece_size",
		Help:    "Track the request object piece payload size.",
		Buckets: prometheus.DefBuckets,
	}, []string{"request_piece_size"})

	// task executor mertics items
	ExecutorCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "executor_counter",
		Help: "Track total request counter.",
	}, []string{"request_qps"})
	ExecutorTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "executor_time",
		Help:    "Track the executor time.",
		Buckets: prometheus.DefBuckets,
	}, []string{"request_time"})
	MaxTaskNumberGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "max_task_num",
		Help: "Track the max task number of task executor.",
	}, []string{"max_task_num"})
	RunningTaskNumberGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "running_task_num",
		Help: "Track the running task number of task executor.",
	}, []string{"running_task_num"})
	RemainingMemoryGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "remaining_memory_resource",
		Help: "Track remaining memory size of task executor.",
	}, []string{"remaining_memory_resource"})
	RemainingTaskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "remaining_task_resource",
		Help: "Track remaining resource of total task number.",
	}, []string{"remaining_task_resource"})
	RemainingHighPriorityTaskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "remaining_high_task_resource",
		Help: "Track remaining resource of high priority task number.",
	}, []string{"remaining_high_task_resource"})
	RemainingMediumPriorityTaskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "remaining_medium_task_resource",
		Help: "Track remaining resource of medium task number.",
	}, []string{"remaining_medium_task_resource"})
	RemainingLowTaskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "remaining_low_task_resource",
		Help: "Track remaining resource of low task number.",
	}, []string{"remaining_task_resource"})
	GCObjectCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "delete_object_number",
		Help: "Track deleted object number.",
	}, []string{"delete_object_number"})

	// manager mertics items
	ManagerCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "manager_counter",
		Help: "Track total request counter.",
	}, []string{"request_qps"})
	ManagerTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "manager_time",
		Help:    "Track the manager time.",
		Buckets: prometheus.DefBuckets,
	}, []string{"request_time"})
	GCBlockNumberGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "gc_block_number",
		Help: "Track the next gc block number.",
	}, []string{"gc_block_number"})
)

module metrics items, include gateway, approver, uploader, manager, task executor, receiver, challenge, downloader

View Source
var (
	PerfApprovalTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_approval_time",
		Help:    "Track approval workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_approval_time"})
	PerfPutObjectTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_put_object_time",
		Help:    "Track put object workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_put_object_time"})
)

workflow metrics items

View Source
var (
	PerfAuthTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_auth_time",
		Help:    "Track auth workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_auth_time"})
	PerfReceivePieceTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_receive_time",
		Help:    "Track receive piece workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_receive_time"})
	PerfGetObjectTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_get_object_time",
		Help:    "Track get object workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_get_object_time"})
	PerfChallengeTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "perf_challenge_piece_time",
		Help:    "Track challenge piece workflow costs.",
		Buckets: prometheus.DefBuckets,
	}, []string{"perf_challenge_piece_time"})
)
View Source
var (
	BlocksyncerCatchTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "blocksyncer_catch_time",
		Help: "Track the time of catch block time. ",
	})
	BlocksyncerLogicTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "blocksyncer_logic_time",
		Help: "Track the time of catch block time. ",
	})
	BlocksyncerWriteDBTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "blocksyncer_write_db_time",
		Help: "Track the time of catch block time. ",
	})
	ChainRPCTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "chain_rpc_time",
		Help: "Track the time of chain rpc. ",
	})
	BlockEventCount = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "block_event_count",
		Help: "Track the sql count of block. ",
	})
	ChainLatestHeight = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "chain_latest_height",
		Help: "Track the height of chain. ",
	})
)
View Source
var (
	MigrateGVGTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "migrate_gvg_time",
		Help:    "Track migrate gvg workflow costs",
		Buckets: prometheus.DefBuckets,
	}, []string{"migrate_gvg_time"})
	MigrateGVGCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "migrate_gvg_counter",
		Help: "Track migrate gvg number",
	}, []string{"migrate_gvg_counter"})
	MigrateObjectTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "migrate_object_time",
		Help:    "Track migrate object workflow costs",
		Buckets: prometheus.DefBuckets,
	}, []string{"migrate_object_time"})
	MigrateObjectCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "migrate_object_counter",
		Help: "Track migrate object number",
	}, []string{"migrate_object_counter"})
)

SP exit and bucket migration metrics

View Source
var (
	GoRoutineCount = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "go_routine_count",
		Help: "Track the current go routine count. ",
	})
)
View Source
var (
	MetadataReqTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "metadata_request_time",
		Help:    "Track the metadata request time.",
		Buckets: prometheus.DefBuckets,
	}, []string{"status", "level", "method_name", "code_or_msg"})
)
View Source
var (
	MetricsModularName = strings.ToLower("Metrics")
)

Functions

func AddMetrics added in v1.1.0

func AddMetrics(cs prometheus.Collector)

AddMetrics can be used in external functions to add metrics to MetricsItems.

Types

type Metrics

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

Metrics is used to monitor sp services

func NewMetrics

func NewMetrics(address string) *Metrics

func (*Metrics) Name

func (m *Metrics) Name() string

Name describes metrics service name

func (*Metrics) RegisterMetricItems added in v0.2.2

func (m *Metrics) RegisterMetricItems(cs ...prometheus.Collector)

func (*Metrics) ReleaseResource added in v0.2.2

func (m *Metrics) ReleaseResource(ctx context.Context, scope corercmgr.ResourceScopeSpan)

func (*Metrics) ReserveResource added in v0.2.2

func (m *Metrics) ReserveResource(ctx context.Context, state *corercmgr.ScopeStat) (corercmgr.ResourceScopeSpan, error)

func (*Metrics) Start

func (m *Metrics) Start(ctx context.Context) error

Start HTTP server

func (*Metrics) Stop

func (m *Metrics) Stop(ctx context.Context) error

Stop HTTP server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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