metrics

package module
v0.0.0-...-ef1f688 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetErrorHandler

func SetErrorHandler(f func(error)) func(error)

SetErrorHandler sets a function to be called when an error happens while creating or recording a metric. It returns the previous value.

The default error handler prints the error to stderr.

Types

type Counter

type Counter[N Number] struct {
	// contains filtered or unexported fields
}

A Counter is a cumulative count that is always increasing.

func NewCounter

func NewCounter[N Number](meter ometric.Meter, name, desc string) *Counter[N]

NewCounter creates and registers a Counter.

The corresponding metric has the given name and description, and is cumulative and summable. If N is time.Duration, the unit will be "ns" (the UCUM name for nanonseconds). If N has a method

Unit() string

then the unit will be the result of calling that method on a zero value of N. Otherwise, the unit will be the empty string.

func (*Counter[N]) Add

func (c *Counter[N]) Add(n N)

Add adds n to the value of the counter. If n is negative, NaN, or infinity, it is not added and the error handler (see SetErrorHandler) is called with an appropriate error.

type Group

type Group[I any, Attrs comparable] struct {
	// contains filtered or unexported fields
}

A Group is a collection of instruments, each with a different value of Attrs. Attrs must be a struct.

func NewCounterGroup

func NewCounterGroup[N Number, A comparable](meter ometric.Meter, name, desc string) Group[*Counter[N], A]

NewCounterGroup creates a group of counters that differ in the values of the type A, which must be a struct. See NewCounter for details about the corresponding metric.

func (Group[I, A]) At

func (g Group[I, A]) At(attrs A) I

At returns the instrument for the given attrs, creating one if it does not exist.

type IgnoreValueError

type IgnoreValueError struct {
	Metric string
	Value  any
}

func (*IgnoreValueError) Error

func (e *IgnoreValueError) Error() string

type Number

type Number interface {
	~int64 | ~float64
}

Jump to

Keyboard shortcuts

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