registry

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 4 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 {
	Log logger.Interface
	Met metric.Meter
}

type Interface

type Interface interface {
	// Counter performs a registry lookup for the counter metric matching the
	// provided metric name.
	//
	//     inp[0] the name of the counter metric to fetch
	//
	//     out[0] the interface of the counter metric to work with
	//     out[1] the set of whitelisted labels to work with, if any
	//     out[2] the error describing why the lookup failed, if any
	//
	Counter(string) (metric.Float64Counter, map[string]struct{}, error)

	// Gauge performs a registry lookup for the gauge metric matching the provided
	// metric name.
	//
	//     inp[0] the name of the gauge metric to fetch
	//
	//     out[0] the interface of the gauge metric to work with
	//     out[1] the set of whitelisted labels to work with, if any
	//     out[2] the error describing why the lookup failed, if any
	//
	Gauge(string) (metric.Float64Gauge, map[string]struct{}, error)

	// Histogram performs a registry lookup for the histogram metric matching the
	// provided metric name.
	//
	//     inp[0] the name of the histogram metric to fetch
	//
	//     out[0] the interface of the histogram metric to work with
	//     out[1] the set of whitelisted labels to work with, if any
	//     out[2] the error describing why the lookup failed, if any
	//
	Histogram(string) (metric.Float64Histogram, map[string]struct{}, error)
}

Interface provides a mechanism for the server and worker handlers to get the metrics they are interested in. This abstract metrics registry defines the whitelist of available metrics. The consumers, here server and worker handlers, will use the registry to get 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

func (*Registry) Counter

func (r *Registry) Counter(string) (metric.Float64Counter, map[string]struct{}, error)

func (*Registry) Gauge

func (r *Registry) Gauge(string) (metric.Float64Gauge, map[string]struct{}, error)

func (*Registry) Histogram

func (r *Registry) Histogram(string) (metric.Float64Histogram, map[string]struct{}, error)

Jump to

Keyboard shortcuts

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