metrics

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValueObserver1

type ValueObserver1[T any] interface {
	Observe(val T, metric float64)
}

ValueObserver1 is a callback interface that is called with a piece of data and a metric value. This can be used to record durations of different metrics based on the supplied value.

type ValueObserver2

type ValueObserver2[T any, U any] interface {
	Observe(val1 T, val2 U, metric float64)
}

ValueObserver2 is a callback interface that is called with a piece of data and a metric value. This can be used to record durations of different metrics based on the supplied values.

type ValueObserver3

type ValueObserver3[T any, U any, V any] interface {
	Observe(val1 T, val2 U, val3 V, metric float64)
}

ValueObserver3 is a callback interface that is called with a piece of data and a metric value. This can be used to record durations of different metrics based on the supplied values.

type ValueObserver4

type ValueObserver4[T any, U any, V any, W any] interface {
	Observe(val1 T, val2 U, val3 V, val4 W, metric float64)
}

ValueObserver4 is a callback interface that is called with a piece of data and a metric value. This can be used to record durations of different metrics based on the supplied values.

type ValueObserver5

type ValueObserver5[T any, U any, V any, W any, X any] interface {
	Observe(val1 T, val2 U, val3 V, val4 W, val5 X, metric float64)
}

ValueObserver5 is a callback interface that is called with a piece of data and a metric value. This can be used to record durations of different metrics based on the supplied values.

type ValueObserverFunc1

type ValueObserverFunc1[T any] func(val T, metric float64)

ValueObserverFunc1 is a functional implementation of ValueObserver1 interface.

func (ValueObserverFunc1[T]) Observe

func (r ValueObserverFunc1[T]) Observe(v T, metric float64)

type ValueObserverFunc2

type ValueObserverFunc2[T any, U any] func(val1 T, val2 U, metric float64)

ValueObserverFunc2 is a functional implementation of ValueObserver2 interface.

func (ValueObserverFunc2[T, U]) Observe

func (r ValueObserverFunc2[T, U]) Observe(v1 T, v2 U, metric float64)

type ValueObserverFunc3

type ValueObserverFunc3[T any, U any, V any] func(val1 T, val2 U, val3 V, metric float64)

ValueObserverFunc3 is a functional implementation of ValueObserver3 interface.

func (ValueObserverFunc3[T, U, V]) Observe

func (r ValueObserverFunc3[T, U, V]) Observe(v1 T, v2 U, v3 V, metric float64)

type ValueObserverFunc4

type ValueObserverFunc4[T any, U any, V any, W any] func(val1 T, val2 U, val3 V, val4 W, metric float64)

ValueObserverFunc4 is a functional implementation of ValueObserver4 interface.

func (ValueObserverFunc4[T, U, V, W]) Observe

func (r ValueObserverFunc4[T, U, V, W]) Observe(v1 T, v2 U, v3 V, v4 W, metric float64)

type ValueObserverFunc5

type ValueObserverFunc5[T any, U any, V any, W any, X any] func(val1 T, val2 U, val3 V, val4 W, val5 X, metric float64)

ValueObserverFunc5 is a functional implementation of ValueObserver5 interface.

func (ValueObserverFunc5[T, U, V, W, X]) Observe

func (r ValueObserverFunc5[T, U, V, W, X]) Observe(v1 T, v2 U, v3 V, v4 W, v5 X, metric float64)

type ValueTimer1

type ValueTimer1[T any] struct {
	Observer ValueObserver1[T]
	// contains filtered or unexported fields
}

ValueTimer1 is a timer that calls the supplied observer function. When the ObserveValuesAndDuration method is called the supplied observer function is called with the provided data and the time it took since the instantiation of the ValueTimer1.

It is similar to prometheus.Timer but unlike it, this can also process the supplied data. This means though that it is not possible to defer the execution of the ValueTimer1 rather it is expected that is called right before the return from a function. See ObserveValuesAndDuration for more details.

func NewValueTimer1

func NewValueTimer1[T any](observer ValueObserver1[T]) ValueTimer1[T]

func (ValueTimer1[T]) ObserveValuesAndDuration

func (o ValueTimer1[T]) ObserveValuesAndDuration(val T) T

ObserveValuesAndDuration calls the stored observer with the supplied data and the time it took since the instantiation of the ValueTimer1 to this call. It also returns the supplied data.

The intended usage is for wrapping the call to a function, use the returned value (or values in case of ValueTimer2 and others) to determine which metrics to observe and how and then return the value as if the metrics collection wasn't there.

E.g.:

timer := metrics.NewValueTimer1[int](metrics.ValueObserverFunc1[int](func (val int, duration float64) {
  if val > 1 {
     counter.Inc()
  } else {
     histo.Observe(val)
  }
}))

returnValue := timer.ObserverValuesAndDuration(expensiveCall())

type ValueTimer2

type ValueTimer2[T any, U any] struct {
	Observer ValueObserver2[T, U]
	// contains filtered or unexported fields
}

ValueTimer2 is similar to ValueTimer1 but can be used with functions returning two values.

func NewValueTimer2

func NewValueTimer2[T any, U any](observer ValueObserver2[T, U]) ValueTimer2[T, U]

func (ValueTimer2[T, U]) ObserveValuesAndDuration

func (o ValueTimer2[T, U]) ObserveValuesAndDuration(v1 T, v2 U) (T, U)

ObserveValuesAndDuration calls the stored observer with the supplied data and the time it took since the instantiation of the ValueTimer2 to this call. It also returns the supplied data.

type ValueTimer3

type ValueTimer3[T any, U any, V any] struct {
	Observer ValueObserver3[T, U, V]
	// contains filtered or unexported fields
}

ValueTimer3 is similar to ValueTimer1 but can be used with functions returning three values.

func NewValueTimer3

func NewValueTimer3[T any, U any, V any](observer ValueObserver3[T, U, V]) ValueTimer3[T, U, V]

func (ValueTimer3[T, U, V]) ObserveValuesAndDuration

func (o ValueTimer3[T, U, V]) ObserveValuesAndDuration(v1 T, v2 U, v3 V) (T, U, V)

ObserveValuesAndDuration calls the stored observer with the supplied data and the time it took since the instantiation of the ValueTimer3 to this call. It also returns the supplied data.

type ValueTimer4

type ValueTimer4[T any, U any, V any, W any] struct {
	Observer ValueObserver4[T, U, V, W]
	// contains filtered or unexported fields
}

ValueTimer4 is similar to ValueTimer1 but can be used with functions returning four values.

func NewValueTimer4

func NewValueTimer4[T any, U any, V any, W any](observer ValueObserver4[T, U, V, W]) ValueTimer4[T, U, V, W]

func (ValueTimer4[T, U, V, W]) ObserveValuesAndDuration

func (o ValueTimer4[T, U, V, W]) ObserveValuesAndDuration(v1 T, v2 U, v3 V, v4 W) (T, U, V, W)

ObserveValuesAndDuration calls the stored observer with the supplied data and the time it took since the instantiation of the ValueTimer4 to this call. It also returns the supplied data.

type ValueTimer5

type ValueTimer5[T any, U any, V any, W any, X any] struct {
	Observer ValueObserver5[T, U, V, W, X]
	// contains filtered or unexported fields
}

ValueTimer5 is similar to ValueTimer1 but can be used with functions returning five values.

func NewValueTimer5

func NewValueTimer5[T any, U any, V any, W any, X any](observer ValueObserver5[T, U, V, W, X]) ValueTimer5[T, U, V, W, X]

func (ValueTimer5[T, U, V, W, X]) ObserveValuesAndDuration

func (o ValueTimer5[T, U, V, W, X]) ObserveValuesAndDuration(v1 T, v2 U, v3 V, v4 W, v5 X) (T, U, V, W, X)

ObserveValuesAndDuration calls the stored observer with the supplied data and the time it took since the instantiation of the ValueTimer5 to this call. It also returns the supplied data.

Jump to

Keyboard shortcuts

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