metrics

package
v3.3.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: LGPL-3.0 Imports: 6 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilPusher         = errors.New("pusher is nil")
	ErrPusherUnavailable = errors.New("pusher addr unavailable")
)

errors

Functions

func InitMetrics

func InitMetrics(c *Client)

InitMetrics inits the defaultClient.

func SetID

func SetID(id string)

SetID sets the ID of metrics client.

func SetPusher

func SetPusher(addr, username, password string) error

SetPusher sets the pusher with the given addr.

func Start

func Start() error

Start starts the pusher loop.

func Stop

func Stop()

Stop stops the pusher loop.

Types

type Client

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

Client is the struct responsible for sending different type of metrics.

func NewClient

func NewClient() *Client

NewClient returns a new Client.

func (*Client) NewCounter

func (c *Client) NewCounter(name string, labels []string) Counter

NewCounter returns a counter-type metrics.

func (*Client) NewGauge

func (c *Client) NewGauge(name string, labels []string) Gauge

NewGauge returns a gauge-type metrics.

func (*Client) NewSummary

func (c *Client) NewSummary(name string, labels []string) Summary

NewSummary returns a summary-type metrics.

func (*Client) SetID

func (c *Client) SetID(id string)

SetID sets the ID of metrics client.

func (*Client) SetPusher

func (c *Client) SetPusher(addr, username, password string) error

SetPusher sets the pusher with the given addr.

func (*Client) Start

func (c *Client) Start() error

Start starts the pusher loop.

func (*Client) Stop

func (c *Client) Stop()

Stop stops the pusher loop.

type Counter

type Counter interface {
	Add(float64, map[string]string) error
}

Counter defines the API of counter-type metrics.

func NewCounter

func NewCounter(name string, labels []string) Counter

NewCounter returns a counter-type metrics.

type Gauge

type Gauge interface {
	Set(float64, map[string]string) error
}

Gauge defines the API of gauge-type metrics.

func NewGauge

func NewGauge(name string, labels []string) Gauge

NewGauge returns a gauge-type metrics.

type PromCounter

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

PromCounter is the implementation of Counter with prometheus's CounterVec.

func NewPromCounter

func NewPromCounter(c *prometheus.CounterVec) *PromCounter

NewPromCounter returns a instance of PromCounter.

func (*PromCounter) Add

func (p *PromCounter) Add(value float64, tagkv map[string]string) error

Add adds the given value to the prometheus Counter.

type PromGauge

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

PromGauge is the implementation of Gauge with prometheus's GaugeVec.

func NewPromGauge

func NewPromGauge(g *prometheus.GaugeVec) *PromGauge

NewPromGauge returns a instance of PromGauge.

func (*PromGauge) Set

func (p *PromGauge) Set(value float64, tagkv map[string]string) error

Set sets the given value to the prometheus Gauge.

type PromSummary

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

PromSummary is the implementation of Summary with prometheus's SummaryVec.

func NewPromSummary

func NewPromSummary(s *prometheus.SummaryVec) *PromSummary

NewPromSummary returns a instance of PromSummary.

func (*PromSummary) Observe

func (p *PromSummary) Observe(value float64, tagkv map[string]string) error

Observe adds the observations to the prometheus Summary.

type Summary

type Summary interface {
	Observe(float64, map[string]string) error
}

Summary defines the API of summary-type metrics.

func NewSummary

func NewSummary(name string, labels []string) Summary

NewSummary returns a summary-type metrics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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