registry

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Env envvar.Env
	Log logger.Interface

	Cou map[string]recorder.Interface
	Gau map[string]recorder.Interface
	His map[string]recorder.Interface
}

type Interface

type Interface interface {
	// Counter performs a metrics update for the counter metric matching the
	// provided metric name, if the given input is considered valid.
	//
	//     inp[0] the name of the counter metric to fetch
	//     inp[1] the value of the counter metric to record
	//     inp[2] the labels of the counter metric to associate
	//
	//     out[0] the error describing why the operation failed, if any
	//
	Counter(string, float64, map[string]string) error

	// Gauge performs a metrics update for the gauge metric matching the provided
	// metric name, if the given input is considered valid.
	//
	//     inp[0] the name of the gauge metric to fetch
	//     inp[1] the value of the gauge metric to record
	//     inp[2] the labels of the gauge metric to associate
	//
	//     out[0] the error describing why the operation failed, if any
	//
	Gauge(string, float64, map[string]string) error

	// Histogram performs a metrics update for the histogram metric matching the
	// provided metric name, if the given input is considered valid.
	//
	//     inp[0] the name of the histogram metric to fetch
	//     inp[1] the value of the histogram metric to record
	//     inp[2] the labels of the histogram metric to associate
	//
	//     out[0] the error describing why the operation failed, if any
	//
	Histogram(string, float64, map[string]string) error
}

Interface provides a mechanism for the server and worker handlers to record the metrics they are responsible for. This abstract metrics registry defines the whitelist of available metrics. The consumers, here Specta's server and worker handlers, use this registry to manage their desired metrics on demand. It is important for the registry to only provide predefined metrics for timeseries that we want to track deliberately. E.g. it should not be possible for the outside world to create metrics or labels arbitrarily based on user input.

type Registry

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

func New

func New(c Config) *Registry

New creates the fully configured registry whitelisting the set of counter metrics that are allowed to be tracked via the Specta RPCs.

func (*Registry) Counter

func (r *Registry) Counter(nam string, val float64, lab map[string]string) error

func (*Registry) Gauge

func (r *Registry) Gauge(nam string, val float64, lab map[string]string) error

func (*Registry) Histogram

func (r *Registry) Histogram(nam string, val float64, lab map[string]string) error

Jump to

Keyboard shortcuts

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