metrics

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 8 Imported by: 12

Documentation

Index

Constants

View Source
const ID = "metrics"

ID declares public service name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	// Namespace of the metric.
	Namespace string

	// Subsystem of the metric.
	Subsystem string

	// Collector type (histogram, gauge, counter, summary).
	Type string

	// Help of collector.
	Help string

	// Labels for vectorized metrics.
	Labels []string

	// Buckets for histogram metric.
	Buckets []float64
}

Collector describes single application specific metric.

type Config

type Config struct {
	// Address to listen
	Address string

	// Collect define application specific metrics.
	Collect map[string]Collector
}

Config configures metrics service.

func (*Config) Hydrate

func (c *Config) Hydrate(cfg service.Config) error

Hydrate configuration.

type Metric

type Metric struct {
	// Collector name.
	Name string

	// Collector value.
	Value float64

	// Labels associated with metric. Only for vector metrics. Must be provided in a form of label values.
	Labels []string
}

Metric represent single metric produced by the application.

type Service

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

Service to manage application metrics using Prometheus.

func (*Service) Collector

func (s *Service) Collector(name string) prometheus.Collector

Collector returns application specific collector by name or nil if collector not found.

func (*Service) Enabled

func (s *Service) Enabled() bool

Enabled indicates that server is able to collect metrics.

func (*Service) Init

func (s *Service) Init(cfg *Config, r *rpc.Service) (bool, error)

Init service.

func (*Service) MustRegister

func (s *Service) MustRegister(c prometheus.Collector)

MustRegister registers new collector or fails with panic.

func (*Service) Register

func (s *Service) Register(c prometheus.Collector) error

Register new prometheus collector.

func (*Service) Serve

func (s *Service) Serve() error

Serve prometheus metrics service.

func (*Service) Stop

func (s *Service) Stop()

Stop prometheus metrics service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳