metrics

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 9 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CounterAdd

func CounterAdd(name string, val float64, labels map[string]string) error

CounterAdd increase value of a collector

func CounterValue added in v2.7.0

func CounterValue(name string, labels map[string]string) float64

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 summary type

func CreateSummary

func CreateSummary(opts SummaryOpts) error

CreateSummary init a new summary type

func EnableRunTimeMetrics

func EnableRunTimeMetrics()

EnableRunTimeMetrics enable runtime metrics

func GaugeAdd added in v2.3.0

func GaugeAdd(name string, val float64, labels map[string]string) error

GaugeAdd set a new value to a collector

func GaugeSet

func GaugeSet(name string, val float64, labels map[string]string) error

GaugeSet set a new value to a collector

func GaugeValue added in v2.7.0

func GaugeValue(name string, labels map[string]string) float64

func GetSystemPrometheusRegistry

func GetSystemPrometheusRegistry() *prometheus.Registry

GetSystemPrometheusRegistry return prometheus registry which go chassis use

func HistogramObserve

func HistogramObserve(name string, val float64, labels map[string]string) error

HistogramObserve gives a value to histogram collector

func Init

func Init() error

Init load the metrics plugin and initialize it

func InstallPlugin

func InstallPlugin(name string, f NewRegistry)

InstallPlugin install metrics registry

func Reset added in v2.3.0

func Reset(name string) error

Reset clear collector metrics

func Split added in v2.3.0

func Split(key string) (string, string, string)

func SummaryObserve

func SummaryObserve(name string, val float64, labels map[string]string) error

SummaryObserve gives a value to summary collector

func SummaryValue added in v2.7.0

func SummaryValue(name string, labels map[string]string) (uint64, float64)

Types

type CounterOpts

type CounterOpts struct {
	// Key is the key set joining with '_', Name will be ignored when Key is not empty
	Key    string
	Name   string
	Help   string
	Labels []string
}

CounterOpts is options to create a counter options

type GaugeOpts

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

GaugeOpts is options to create a gauge collector

type HistogramOpts

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

HistogramOpts is options to create histogram collector

type NewRegistry

type NewRegistry func(opts Options) Registry

NewRegistry create a registry

type Options

type Options struct {
	FlushInterval          time.Duration
	EnableGoRuntimeMetrics bool
}

Options control config

type PrometheusExporter

type PrometheusExporter struct {
	FlushInterval time.Duration
	// contains filtered or unexported fields
}

PrometheusExporter is a prom exporter for go chassis

func (*PrometheusExporter) CounterAdd

func (c *PrometheusExporter) CounterAdd(name string, val float64, labels map[string]string) error

CounterAdd increase value

func (*PrometheusExporter) CounterValue added in v2.7.0

func (c *PrometheusExporter) CounterValue(name string, labels map[string]string) float64

func (*PrometheusExporter) CreateCounter

func (c *PrometheusExporter) CreateCounter(opts CounterOpts) error

CreateCounter create collector

func (*PrometheusExporter) CreateGauge

func (c *PrometheusExporter) CreateGauge(opts GaugeOpts) error

CreateGauge create collector

func (*PrometheusExporter) CreateHistogram

func (c *PrometheusExporter) CreateHistogram(opts HistogramOpts) error

CreateHistogram create collector

func (*PrometheusExporter) CreateSummary

func (c *PrometheusExporter) CreateSummary(opts SummaryOpts) error

CreateSummary create collector

func (*PrometheusExporter) GaugeAdd added in v2.3.0

func (c *PrometheusExporter) GaugeAdd(name string, val float64, labels map[string]string) error

GaugeAdd add value, can be negative

func (*PrometheusExporter) GaugeSet

func (c *PrometheusExporter) GaugeSet(name string, val float64, labels map[string]string) error

GaugeSet set value

func (*PrometheusExporter) GaugeValue added in v2.7.0

func (c *PrometheusExporter) GaugeValue(name string, labels map[string]string) float64

func (*PrometheusExporter) HistogramObserve

func (c *PrometheusExporter) HistogramObserve(name string, val float64, labels map[string]string) error

HistogramObserve set value

func (*PrometheusExporter) Reset added in v2.3.0

func (c *PrometheusExporter) Reset(name string) error

Reset reset a collector metrics

func (*PrometheusExporter) SummaryObserve

func (c *PrometheusExporter) SummaryObserve(name string, val float64, labels map[string]string) error

SummaryObserve set value

func (*PrometheusExporter) SummaryValue added in v2.7.0

func (c *PrometheusExporter) SummaryValue(name string, labels map[string]string) (uint64, float64)

type Registry

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

	GaugeSet(name string, val float64, labels map[string]string) error
	GaugeAdd(name string, val float64, labels map[string]string) error
	CounterAdd(name string, val float64, labels map[string]string) error
	SummaryObserve(name string, val float64, Labels map[string]string) error
	HistogramObserve(name string, val float64, labels map[string]string) error

	GaugeValue(name string, labels map[string]string) float64
	CounterValue(name string, labels map[string]string) float64
	SummaryValue(name string, labels map[string]string) (uint64, float64)

	Reset(name string) error
}

Registry holds all of metrics collectors name is a unique ID for different type of metrics

func NewPrometheusExporter

func NewPrometheusExporter(options Options) Registry

NewPrometheusExporter create a prometheus exporter

type SummaryOpts

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

SummaryOpts is options to create summary collector

Jump to

Keyboard shortcuts

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