metric

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Name = "metric"

Functions

func Count

func Count(name string, value float64, tags Tags) error

Count 上报递增数据

func CreateCounter

func CreateCounter(opts CounterOpts) error

CreateCounter init a new counter type

func CreateGauge

func CreateGauge(opts GaugeOpts) error

CreateGauge init a new gauge type

func CreateHistogram

func CreateHistogram(opts HistogramOpts) error

CreateHistogram init a new histogram type

func CreateSummary

func CreateSummary(opts SummaryOpts) error

CreateSummary init a new summary type

func Gauge

func Gauge(name string, value float64, tags Tags) error

Gauge 实时的上报当前指标

func Histogram

func Histogram(name string, value float64, tags Tags) error

Histogram 存储区间数据, 在服务端端聚合数据

func Register

func Register(name string, r Factory) (err error)

func SetDefault

func SetDefault(reporter Reporter)

SetDefault 设置全局的Reporter

func Summary

func Summary(name string, value float64, tags Tags) error

Summary 在client端聚合数据, 直接存储了分位数

Types

type Cfg

type Cfg struct {
	Driver string `json:"driver"`
}

func GetDefaultCfg

func GetDefaultCfg() Cfg

func (Cfg) Build

func (cfg Cfg) Build() (_ Reporter, err error)

type CounterOpts

type CounterOpts struct {
	Name   string
	Help   string
	Labels []string
}

CounterOpts is options to create a counter options

type Factory

type Factory func(cfg map[string]interface{}) (Reporter, error)

func Get

func Get(names ...string) Factory

type GaugeOpts

type GaugeOpts struct {
	Name   string
	Help   string
	Labels []string
}

GaugeOpts is options to create a gauge collector

type HistogramOpts

type HistogramOpts struct {
	Name    string
	Help    string
	Labels  []string
	Buckets []float64
}

HistogramOpts is options to create histogram collector

type Reporter

type Reporter interface {
	CreateGauge(opts GaugeOpts) error
	CreateCounter(opts CounterOpts) error
	CreateSummary(opts SummaryOpts) error
	CreateHistogram(opts HistogramOpts) error

	Count(name string, value float64, tags Tags) error
	Gauge(name string, value float64, tags Tags) error
	Histogram(name string, value float64, tags Tags) error
	Summary(name string, value float64, tags Tags) error
}

Reporter is an interface for collecting and instrumenting metrics

type SummaryOpts

type SummaryOpts struct {
	Name       string
	Help       string
	Labels     []string
	Objectives map[float64]float64
}

SummaryOpts is options to create summary collector

type Tags

type Tags map[string]string

Tags is a map of fields to add to a metrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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