metrics

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferMetrics

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

BufferMetrics contains the pre-bound metric handles for one buffer. Keeping these handles avoids a label lookup on every buffered item.

func (*BufferMetrics) Buffered

func (m *BufferMetrics) Buffered()

func (*BufferMetrics) Closed

func (m *BufferMetrics) Closed()

Closed records an attempted write after the buffer has begun closing.

func (*BufferMetrics) Dropped

func (m *BufferMetrics) Dropped()

func (*BufferMetrics) SetFillRatio

func (m *BufferMetrics) SetFillRatio(value float64)

type Metrics

type Metrics struct {
	// BufferState is a counter to track the number of times a buffer is used and
	// what state is triggered.
	//
	// Possible states are:
	// - "buffered": The item was added to the buffer.
	// - "dropped": The item was dropped because the buffer was full.
	// - "closed": An insert was rejected because the buffer was closing or closed.
	//
	// Example usage:
	//   metrics.BufferInserts.WithLabelValues(b.String(), "buffered").Inc()
	BufferState *lazy.CounterVec
	// BufferSize is a gauge to track the fill percentage of buffers and whether or not they
	// are configured to drop on overflow.
	//
	// Example usage:
	// 	 metrics.BufferSize.WithLabelValues(b.String(), "true").Set(float64(capacity)/float64(maxCapacity))
	BufferSize *lazy.GaugeVec
}

func New

func New(namespace string) *Metrics

func (*Metrics) ForBuffer

func (m *Metrics) ForBuffer(name string, drop bool) *BufferMetrics

ForBuffer binds the metric labels used by a buffer. It is nil-safe so the caller can use the returned value when metrics are disabled.

Jump to

Keyboard shortcuts

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