metrics

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ID declares public service name.
	ID = "metrics"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	// Namespace of the metric.
	Namespace string `json:"namespace"`
	// Subsystem of the metric.
	Subsystem string `json:"subsystem"`
	// Collector type (histogram, gauge, counter, summary).
	Type CollectorType `json:"type"`
	// Help of collector.
	Help string `json:"help"`
	// Labels for vectorized metrics.
	Labels []string `json:"labels"`
	// Buckets for histogram metric.
	Buckets []float64 `json:"buckets"`
}

Collector describes single application specific metric.

type CollectorType

type CollectorType string

CollectorType represents prometheus collector types

const (
	// Histogram type
	Histogram CollectorType = "histogram"

	// Gauge type
	Gauge CollectorType = "gauge"

	// Counter type
	Counter CollectorType = "counter"

	// Summary type
	Summary CollectorType = "summary"
)

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 NamedCollector

type NamedCollector struct {
	// Name of the collector
	Name string `json:"name"`

	// Collector structure
	Collector `json:"collector"`
}

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, log *logrus.Logger) (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