metrics

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAverage

func GetAverage(name string, duration time.Duration) *probe.Average

GetAverage retrieves or creates an average metric.

GetAverage operates like GetDuration and GetCounter, handling average metrics. It additionally requires a duration parameter for the new average metric.

Parameters: - name: string - The name of the average metric. - duration: time.Duration - The duration for the average calculation.

Returns: - *probe.Average: Pointer to the retrieved or newly created average metric.

func GetCounter

func GetCounter(name string) *probe.Counter

GetCounter retrieves or creates a counter metric.

Similar to GetDuration, GetCounter looks for an existing counter metric or creates a new one if it doesn't exist, ensuring thread safety with mutex locks.

Parameters: - name: string - The name of the counter metric.

Returns: - *probe.Counter: Pointer to the retrieved or newly created counter metric.

func GetDuration

func GetDuration(name string) *probe.Duration

GetDuration retrieves or creates a duration metric.

GetDuration first attempts to find an existing duration metric by its name. If it doesn't exist, a new one is created and added to the map. It ensures thread safety using mutex locks.

Parameters: - name: string - The name of the duration metric.

Returns: - *probe.Duration: Pointer to the retrieved or newly created duration metric.

Types

type Metrics

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

Metrics structure holds various types of metrics like counters, durations, and averages.

Metrics provides a thread-safe way to create and manage different types of metric probes such as counters, durations, and averages. It uses sync.RWMutex to handle concurrent access.

func New

func New() *Metrics

New creates and returns a new Metrics instance.

New initializes a Metrics instance with empty maps for counters, durations, and averages.

Returns: - *Metrics: Pointer to the newly created Metrics instance.

func (*Metrics) GetAverage

func (m *Metrics) GetAverage(name string, duration time.Duration) *probe.Average

GetAverage retrieves or creates an average metric.

GetAverage operates like GetDuration and GetCounter, handling average metrics. It additionally requires a duration parameter for the new average metric.

Parameters: - name: string - The name of the average metric. - duration: time.Duration - The duration for the average calculation.

Returns: - *probe.Average: Pointer to the retrieved or newly created average metric.

func (*Metrics) GetCounter

func (m *Metrics) GetCounter(name string) *probe.Counter

GetCounter retrieves or creates a counter metric.

Similar to GetDuration, GetCounter looks for an existing counter metric or creates a new one if it doesn't exist, ensuring thread safety with mutex locks.

Parameters: - name: string - The name of the counter metric.

Returns: - *probe.Counter: Pointer to the retrieved or newly created counter metric.

func (*Metrics) GetDuration

func (m *Metrics) GetDuration(name string) *probe.Duration

GetDuration retrieves or creates a duration metric.

GetDuration first attempts to find an existing duration metric by its name. If it doesn't exist, a new one is created and added to the map. It ensures thread safety using mutex locks.

Parameters: - name: string - The name of the duration metric.

Returns: - *probe.Duration: Pointer to the retrieved or newly created duration metric.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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