telemetry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Gatherer prometheus.Gatherer // The gatherer is for fetching metrics from the registry.

)

registerer is the global metrics center for collecting the telemetry data in core modules or plugins.

Functions

func Init

func Init(c *Config)

Init create the global telemetry center according to the config.

func Register

func Register(meta ...SelfTelemetryMetaFunc)

Register registers the metric meta to the registerer.

Types

type Collector

type Collector interface {
}

The Self-telemetry data collection interface.

type Config

type Config struct {
	Cluster  string `mapstructure:"cluster"`  // The cluster name.
	Service  string `mapstructure:"service"`  // The service name.
	Instance string `mapstructure:"instance"` // The instance name.
}

Config defines the common telemetry labels.

type Counter

type Counter struct {
	Collector
	// contains filtered or unexported fields
}

The counter metric.

func NewCounter

func NewCounter(name, help string, labels ...string) *Counter

NewCounter create a new counter if no metric with the same name exists.

func (*Counter) Add

func (c *Counter) Add(val float64, labelValues ...string)

Add float value.

func (*Counter) Inc

func (c *Counter) Inc(labelValues ...string)

Add one.

type DynamicGauge added in v0.4.0

type DynamicGauge struct {
	Collector
	// contains filtered or unexported fields
}

func NewDynamicGauge added in v0.4.0

func NewDynamicGauge(name, help string, labels ...string) *DynamicGauge

func (*DynamicGauge) Dec added in v0.4.0

func (i *DynamicGauge) Dec(labels ...string)

func (*DynamicGauge) Inc added in v0.4.0

func (i *DynamicGauge) Inc(labels ...string)

type Gauge added in v0.4.0

type Gauge struct {
	Collector
	// contains filtered or unexported fields
}

func NewGauge added in v0.4.0

func NewGauge(name, help string, getter func() float64, labels ...string) *Gauge

type SelfTelemetryMetaFunc

type SelfTelemetryMetaFunc func() (string, prometheus.Collector)

SelfTelemetryMetaFunc returns the metric name and the metric instance.

func WithMeta

func WithMeta(name string, collector prometheus.Collector) SelfTelemetryMetaFunc

WithMeta is used as the param of the Register function.

type TimeRecorder added in v0.4.0

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

func (*TimeRecorder) Stop added in v0.4.0

func (c *TimeRecorder) Stop()

Stop the time and record the time

type Timer added in v0.4.0

type Timer struct {
	Collector
	// contains filtered or unexported fields
}

func NewTimer added in v0.4.0

func NewTimer(name, help string, labels ...string) *Timer

NewCounter create a new counter if no metric with the same name exists.

func (*Timer) AddTime added in v0.4.0

func (c *Timer) AddTime(t time.Duration, labelValues ...string)

AddTime add a new duration and count

func (*Timer) Start added in v0.4.0

func (c *Timer) Start(labelValues ...string) *TimeRecorder

Start a new time recorder

Jump to

Keyboard shortcuts

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