metrics

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: Apache-2.0 Imports: 8 Imported by: 3

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 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 added in v1.3.0

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 added in v1.7.2

func EnableRunTimeMetrics()

EnableRunTimeMetrics enable runtime metrics

func GaugeSet

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

GaugeSet set a new value to a collector

func GetSystemPrometheusRegistry

func GetSystemPrometheusRegistry() *prometheus.Registry

GetSystemPrometheusRegistry return prometheus registry which go chassis use

func HTTPHandleFunc added in v1.4.1

func HTTPHandleFunc(req *restful.Request, rep *restful.Response)

HTTPHandleFunc is a go-restful handler which can expose metrics in http server

func HistogramObserve added in v1.3.0

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 SummaryObserve

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

SummaryObserve gives a value to summary collector

Types

type CounterOpts

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

CounterOpts is options to create a counter options

type GaugeOpts

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

GaugeOpts is options to create a gauge collector

type HistogramOpts added in v1.3.0

type HistogramOpts struct {
	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
}

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) 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 added in v1.3.0

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) GaugeSet

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

GaugeSet set value

func (*PrometheusExporter) HistogramObserve added in v1.3.0

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

HistogramObserve set value

func (*PrometheusExporter) SummaryObserve

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

SummaryObserve set value

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
	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
}

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 {
	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