metric

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FamilyName = "service_center"
)

Variables

View Source
var (
	// Period is metrics collect period
	Period = 30 * time.Second
	// SysMetrics map
	SysMetrics util.ConcurrentMap
)
View Source
var Pxx = map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}

Pxx represents p99 p90 p50

Functions

func InstanceName

func InstanceName() string

func RegisterCalculator

func RegisterCalculator(c Calculator)

func RegisterReporter

func RegisterReporter(name string, r Reporter)

func Report

func Report()

func ToLabelNames

func ToLabelNames(structure interface{}) []string

ToLabelNames returns label names, count is special label of v of func ForEach

func ToRawData

func ToRawData(result interface{}, labels []*dto.LabelPair)

ToRawData parses result form labels

Types

type Calculator

type Calculator interface {
	Calc(mf *dto.MetricFamily) *Details
}

Calculator is the interface to implement customize algorithm of MetricFamily

var (
	DefaultCalculator Calculator = &CommonCalculator{}
)

type CommonCalculator

type CommonCalculator struct {
}

func (*CommonCalculator) Calc

func (c *CommonCalculator) Calc(mf *dto.MetricFamily) *Details

Get value of metricFamily

type Details

type Details struct {
	// Summary is the calculation results of the details
	Summary float64
	// contains filtered or unexported fields
}

Details is the struct to hold the calculated result and index by metric label

func Calculate

func Calculate(mf *dto.MetricFamily) *Details

func NewDetails

func NewDetails() *Details

func (*Details) ForEach

func (cm *Details) ForEach(f func(labels []*dto.LabelPair, v float64) (next bool))

func (*Details) Get

func (cm *Details) Get(labels []*dto.LabelPair) (val float64)

type Metrics

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

Metrics is the struct to hold the Details objects store and index by metric name

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) ForEach

func (cm *Metrics) ForEach(f func(k string, v *Details) (next bool))

func (*Metrics) Get

func (cm *Metrics) Get(key string) (val *Details)

func (*Metrics) Summary

func (cm *Metrics) Summary(key string) (sum float64)

type MetricsGatherer

type MetricsGatherer struct {
	Records *Metrics
	// contains filtered or unexported fields
}
var Gatherer *MetricsGatherer

Gatherer is the reader of sc metrics

func NewGatherer

func NewGatherer() *MetricsGatherer

func (*MetricsGatherer) Collect

func (mm *MetricsGatherer) Collect() error

func (*MetricsGatherer) Start

func (mm *MetricsGatherer) Start()

type Reporter

type Reporter interface {
	Report()
}

Reporter is the interface to implement handler to process metrics after calculate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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