monitor

package
v0.0.0-...-0b0b130 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metric

type Metric struct {
	Type        MetricType
	Name        string
	Description string
	Labels      []string
	Buckets     []float64
	Objectives  map[float64]float64
	// contains filtered or unexported fields
}

Metric 定义度量对象, 用户可以使用它来保存度量数据,每个指标都应该是全局唯一的

func (*Metric) Add

func (m *Metric) Add(labelValues []string, value float64) error

Add 将给定的值添加到Metric对象仅,适用于Counter/Gauge

func (*Metric) Inc

func (m *Metric) Inc(labelValues []string) error

Inc 增加Counter或者Gauge类型的Metric的值,计数器增加1

func (*Metric) Observe

func (m *Metric) Observe(labelValues []string, value float64) error

Observe 被用作 Histogram 和 Summary 类型的Metric

func (*Metric) SetGaugeValue

func (m *Metric) SetGaugeValue(labelValues []string, value float64) error

SetGaugeValue 设置Gauge类型的Metric值

type MetricType

type MetricType int
const (
	None MetricType = iota
	Counter
	Gauge
	Histogram
	Summary
)

type Monitor

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

func NewMonitor

func NewMonitor(metricPath string, slowTime int32, reqDuration []float64) *Monitor

NewMonitor 初始化一个Monitor结构体对象

func (*Monitor) AddMetric

func (m *Monitor) AddMetric(metric *Metric) error

AddMetric 添加metric

func (*Monitor) GetMetric

func (m *Monitor) GetMetric(name string) *Metric

GetMetric 通过metric名获取Metric对象

func (*Monitor) Use

func (m *Monitor) Use(r *gin.Engine)

Use set gin metrics middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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