metrics

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCollector

func RegisterCollector[T Collector](newFunc NewCollectorFunc[T])

RegisterCollector registers a new collector type with the metrics package.

Types

type Collector

type Collector interface {
	// Name returns the name of the collector.
	Name() string
	// Type returns the type of the collector.
	Type() string
	// Configure sets up the collector with the provided settings.
	Configure(settings map[string]any) error
	// Run continuously runs the collection process until the context is
	// cancelled. The function should block until the context is cancelled, an
	// error occurs, or the Stop function is called.
	Run(ctx context.Context) error
	// Results returns the collected metrics.
	Results() []Results
}

func NewCollector

func NewCollector(logger *slog.Logger, name string, collectorType string) (Collector, error)

type NewCollectorFunc

type NewCollectorFunc[T Collector] func(logger *slog.Logger, name string) T

type Results

type Results struct {
	// Name is the name of the metric.
	Name string
	// Samples is a list of samples collected by the collector.
	Samples []Sample
	// Unit is the unit of the metric (optional).
	Unit string
}

type Sample

type Sample struct {
	At    time.Time
	Value float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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