metric

package
v1.0.44 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBuckets    = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
	DefaultObjectives = map[float64]float64{.5: .05, .8: .01, .9: .01, .95: .001, .99: .001}
)
View Source
var (
	ErrMetricExists         = errors.New("metric exists")
	ErrMetricNotExists      = errors.New("metric not exists")
	ErrUnknownMetricType    = errors.New("unknown metric type")
	ErrMetricTypeNotMatches = errors.New("metric type not matches")
)
View Source
var DefaultMetricClient = NewMetricClient()

Functions

func EmitCounter

func EmitCounter(name string, value float64, parser LabelsParser) error

func EmitGauge

func EmitGauge(name string, value float64, parser LabelsParser) error

func EmitHistogram

func EmitHistogram(name string, value float64, parser LabelsParser) error

func EmitHistogramTimer

func EmitHistogramTimer(name string, t time.Time, parser LabelsParser) error

func EmitSummary

func EmitSummary(name string, value float64, parser LabelsParser) error

func EmitSummaryTimer

func EmitSummaryTimer(name string, t time.Time, parser LabelsParser) error

func Model

func Model(parser LabelsParser) (keys []string)

func Register

func Register(r *echo.Echo, prefixes ...string)

func RouterRegister

func RouterRegister(g *echo.Group, prefixes ...string)

func SetMetricClient

func SetMetricClient(c *MetricClient)

Types

type LabelsParser

type LabelsParser interface {
	ParseToLabels() map[string]string
}

type MetricClient

type MetricClient struct {
	Namespace    string
	GlobalLabels prometheus.Labels
	AllMetrics   sync.Map
}

func NewMetricClient

func NewMetricClient(opts ...MetricClientOption) (c *MetricClient)

func (*MetricClient) DefineCounter

func (c *MetricClient) DefineCounter(name string, parser LabelsParser) error

func (*MetricClient) DefineGauge

func (c *MetricClient) DefineGauge(name string, parser LabelsParser) error

func (*MetricClient) DefineHistogram

func (c *MetricClient) DefineHistogram(name string, parser LabelsParser, buckets []float64) error

func (*MetricClient) DefineSummary

func (c *MetricClient) DefineSummary(name string, parser LabelsParser, objectives map[float64]float64) error

func (*MetricClient) EmitCounter

func (c *MetricClient) EmitCounter(name string, value float64, parser LabelsParser) error

func (*MetricClient) EmitGauge

func (c *MetricClient) EmitGauge(name string, value float64, parser LabelsParser) error

func (*MetricClient) EmitHistogram

func (c *MetricClient) EmitHistogram(name string, value float64, parser LabelsParser) error

func (*MetricClient) EmitSummary

func (c *MetricClient) EmitSummary(name string, value float64, parser LabelsParser) error

type MetricClientOption

type MetricClientOption func(*MetricClient)

func WithGlobalLabel

func WithGlobalLabel(key, value string) MetricClientOption

func WithNamespace

func WithNamespace(namespace string) MetricClientOption

type MetricType

type MetricType int
const (
	MetricTypeCounter MetricType = iota
	MetricTypeGauge
	MetricTypeHistogram
	MetricTypeSummary
)

func (MetricType) String

func (t MetricType) String() string

Jump to

Keyboard shortcuts

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