metrics

package
v0.1.1-pprof-4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

	// PanicsTotal records the number of rpc panics
	PanicsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "grpc_req_panics_recovered_total",
		Help: "Total number of gRPC requests recovered from internal panic.",
	}, []string{"grpc_type", "grpc_service", "grpc_method"})
	// BlockHeightLagGauge records the current block height of block syncer service
	BlockHeightLagGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "block_syncer_height",
		Help: "Current block number of block syncer progress.",
	}, []string{serviceLabelName})
	// SealObjectTimeHistogram records sealing object time of task node service
	SealObjectTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "task_node_seal_object_time",
		Help:    "Track task node service the time of sealing object on chain.",
		Buckets: prometheus.DefBuckets,
	}, []string{serviceLabelName})
	// SealObjectTotalCounter records total seal object number
	SealObjectTotalCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "task_node_seal_object_total",
		Help: "Track task node service handles total seal object number",
	}, []string{"success_or_failure"})
	// ReplicateObjectTaskGauge records total replicate object number
	ReplicateObjectTaskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "task_node_replicate_object_task_number",
		Help: "Track task node service replicate object task",
	}, []string{serviceLabelName})
	// PieceStoreTimeHistogram records piece store request time
	PieceStoreTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "piece_store_handling_seconds",
		Help:    "Track the latency for piece store requests",
		Buckets: prometheus.DefBuckets,
	}, []string{"method_name"})
	// PieceStoreRequestTotal records piece store total request
	PieceStoreRequestTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "piece_store_total_requests",
		Help: "Track piece store handles total request",
	}, []string{"method_name"})
	SPDBTimeHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "sp_db_handling_seconds",
		Help:    "Track the latency for spdb requests",
		Buckets: prometheus.DefBuckets,
	}, []string{"method_name"})
)

this file is used to write metric items in sp service

Functions

This section is empty.

Types

type Metrics

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

Metrics is used to monitor sp services

func (*Metrics) Enabled

func (m *Metrics) Enabled() bool

Enabled returns whether starts prometheus metrics

func (*Metrics) Name

func (m *Metrics) Name() string

Name describes metrics service name

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

type MetricsConfig

type MetricsConfig struct {
	Enabled     bool   `toml:",omitempty"`
	HTTPAddress string `toml:",omitempty"`
}

MetricsConfig contains the configuration for the metric collection.

type MetricsMonitor

type MetricsMonitor interface {
	lifecycle.Service
	Enabled() bool
}

MetricsMonitor defines abstract method

func GetMetrics

func GetMetrics() MetricsMonitor

GetMetrics gets an instance of MetricsMonitor

func NewMetrics

func NewMetrics(cfg *MetricsConfig) MetricsMonitor

NewMetrics returns a singleton instance of Metrics. Note: enable metrics should call NewMetrics with MetricsConfig and MetricsConfig.Enabled is set true. GetMetrics will return the singleton instance of Metrics to use at anywhere. If NewMetrics is not called, then the metrics is disabled when calls GetMetrics.

type NilMetrics

type NilMetrics struct{}

NilMetrics is a no-op Metrics

func (NilMetrics) Enabled

func (NilMetrics) Enabled() bool

Enabled is a no-op

func (NilMetrics) Name

func (NilMetrics) Name() string

Name is a no-op

func (NilMetrics) Start

func (NilMetrics) Start(ctx context.Context) error

Start is a no-op

func (NilMetrics) Stop

func (NilMetrics) Stop(ctx context.Context) error

Stop is a no-op

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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