metrics

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithServer added in v0.2.5

func WithServer() plugins.Plugin

Types

type Buckets

type Buckets struct {
	Labels  []string  `yaml:"labels"`
	Buckets []float64 `yaml:"buckets"`
}

type Config

type Config struct {
	Addr         string               `yaml:"addr"`
	Counter      []string             `yaml:"counter,omitempty"`
	CounterVec   map[string][]string  `yaml:"counter_vec,omitempty"`
	Gauge        []string             `yaml:"gauge,omitempty"`
	GaugeVec     map[string][]string  `yaml:"gauge_vec,omitempty"`
	Histogram    map[string][]float64 `yaml:"histogram,omitempty"`
	HistogramVec map[string]Buckets   `yaml:"histogram_vec,omitempty"`
}

type ConfigMetrics

type ConfigMetrics struct {
	Config Config `yaml:"metrics"`
}

func (*ConfigMetrics) Default

func (v *ConfigMetrics) Default()

type CounterInterface

type CounterInterface interface {
	// Inc increments the counter by 1. Use Add to increment it by arbitrary
	// non-negative values.
	Inc()
	// Add adds the given value to the counter. It panics if the value is <
	// 0.
	Add(float64)
}

func Counter

func Counter(name string) CounterInterface

Counter is a Metric that represents a single numerical value that only ever goes up. That implies that it cannot be used to count items whose number can also go down, e.g. the number of currently running goroutines. Those "counters" are represented by Gauges.

A Counter is typically used to count requests served, tasks completed, errors occurred, etc.

func CounterVec

func CounterVec(name string, labelNameValue ...string) CounterInterface

CounterVec is a Collector that bundles a set of Counters that all share the same Desc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of HTTP requests, partitioned by response code and method).

type GaugeInterface

type GaugeInterface interface {
	// Set sets the Gauge to an arbitrary value.
	Set(float64)
	// Inc increments the Gauge by 1. Use Add to increment it by arbitrary
	// values.
	Inc()
	// Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary
	// values.
	Dec()
	// Add adds the given value to the Gauge. (The value can be negative,
	// resulting in a decrease of the Gauge.)
	Add(float64)
	// Sub subtracts the given value from the Gauge. (The value can be
	// negative, resulting in an increase of the Gauge.)
	Sub(float64)

	// SetToCurrentTime sets the Gauge to the current Unix time in seconds.
	SetToCurrentTime()
}

func Gauge

func Gauge(name string) GaugeInterface

Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down.

A Gauge is typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of running goroutines.

func GaugeVec

func GaugeVec(name string, labelNameValue ...string) GaugeInterface

GaugeVec is a Collector that bundles a set of Gauges that all share the same Desc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of operations queued, partitioned by user and operation type).

type HistogramInterface

type HistogramInterface interface {
	// Observe adds a single observation to the histogram. Observations are
	// usually positive or zero.
	Observe(float64)
}

func Histogram

func Histogram(name string) HistogramInterface

A Histogram counts individual observations from an event or sample stream in configurable static buckets (or in dynamic sparse buckets as part of the experimental Native Histograms, see below for more details). Similar to a Summary, it also provides a sum of observations and an observation count.

func HistogramVec

func HistogramVec(name string, labelNameValue ...string) HistogramInterface

HistogramVec is a Collector that bundles a set of Histograms that all share the same Desc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. HTTP request latencies, partitioned by status code and method).

type Metrics

type Metrics interface {
	AddHandler(path string, ctrl func(http.ResponseWriter, *http.Request), methods ...string)
}

type Server

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

func New

func New(app env.AppInfo, c Config, l xlog.Logger) *Server

func (*Server) AddHandler

func (v *Server) AddHandler(path string, ctrl func(http.ResponseWriter, *http.Request), methods ...string)

func (*Server) Down

func (v *Server) Down() error

func (*Server) Up

func (v *Server) Up(ctx xc.Context) error

Jump to

Keyboard shortcuts

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