stats

package
v0.1.0-dev.23 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package stats provide a simple real-time metric registry for monitoring and observability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultGaugeCounter

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

func NewDefaultGaugeCounter

func NewDefaultGaugeCounter() *DefaultGaugeCounter

func (*DefaultGaugeCounter) Dec

func (c *DefaultGaugeCounter) Dec(tags ...string) int64

func (*DefaultGaugeCounter) DecBy

func (c *DefaultGaugeCounter) DecBy(delta int64, tags ...string) int64

func (*DefaultGaugeCounter) Inc

func (c *DefaultGaugeCounter) Inc(tags ...string) int64

func (*DefaultGaugeCounter) IncBy

func (c *DefaultGaugeCounter) IncBy(delta int64, tags ...string) int64

func (*DefaultGaugeCounter) NotifyOnChange

func (c *DefaultGaugeCounter) NotifyOnChange(ch chan<- any, tags ...string)

func (*DefaultGaugeCounter) Set

func (c *DefaultGaugeCounter) Set(value int64, tags ...string)

func (*DefaultGaugeCounter) Tags

func (c *DefaultGaugeCounter) Tags() []string

func (*DefaultGaugeCounter) Value

func (c *DefaultGaugeCounter) Value(tags ...string) int64

type DefaultRegistry

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

func NewDefaultRegistry

func NewDefaultRegistry() *DefaultRegistry

func (*DefaultRegistry) Description

func (r *DefaultRegistry) Description(name string) (string, error)

func (*DefaultRegistry) GetMetric

func (r *DefaultRegistry) GetMetric(name string) (Metric, error)

func (*DefaultRegistry) MustGetMetric

func (r *DefaultRegistry) MustGetMetric(name string) Metric

func (*DefaultRegistry) RegisterMetric

func (r *DefaultRegistry) RegisterMetric(name, description string, metric Metric)

type DefaultSequentialCounter

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

func NewDefaultSequentialCounter

func NewDefaultSequentialCounter() *DefaultSequentialCounter

func (*DefaultSequentialCounter) Inc

func (c *DefaultSequentialCounter) Inc(tags ...string) int64

func (*DefaultSequentialCounter) IncBy

func (c *DefaultSequentialCounter) IncBy(delta int64, tags ...string) int64

func (*DefaultSequentialCounter) NotifyOnChange

func (c *DefaultSequentialCounter) NotifyOnChange(ch chan<- any, tags ...string)

func (*DefaultSequentialCounter) Tags

func (c *DefaultSequentialCounter) Tags() []string

func (*DefaultSequentialCounter) Value

func (c *DefaultSequentialCounter) Value(tags ...string) int64

type GaugeCounter

type GaugeCounter interface {
	Metric
	// Set sets the counter to the given value.
	Set(value int64, tags ...string)
	// Inc increments the counter by 1 and returns the new value.
	Inc(tags ...string) int64
	// IncBy increments the counter by delta and returns the new value.
	IncBy(delta int64, tags ...string) int64
	// Dec decrements the counter by 1 and returns the new value.
	Dec(tags ...string) int64
	// DecBy decrements the counter by delta and returns the new value.
	DecBy(delta int64, tags ...string) int64
}

GaugeCounter is a counter that can be set to arbitrary values.

type Metric

type Metric interface {
	// Tags returns the tags of the Metric.
	Tags() []string
	// Value returns the current value of the counter.
	Value(tags ...string) int64
	// NotifyOnChange receives a channel that will be notified when the value of the counter changes.
	NotifyOnChange(ch chan<- any, tags ...string)
}

Metric is a metric that accumulates values monotonically.

type Registry

type Registry interface {
	RegisterMetric(name, description string, metric Metric)
	GetMetric(name string) (Metric, error)
	MustGetMetric(name string) Metric
	Description(name string) (string, error)
}

type SequentialCounter

type SequentialCounter interface {
	Metric
	// Inc increments the counter by 1 and returns the new value.
	Inc(tags ...string) int64
	// IncBy increments the counter by delta and returns the new value.
	IncBy(delta int64, tags ...string) int64
}

SequentialCounter is a counter that can only be incremented.

type Stats

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

func New

func New() *Stats

func (*Stats) GetGaugeCounter

func (s *Stats) GetGaugeCounter(name string) (GaugeCounter, error)

func (*Stats) GetSequentialCounter

func (s *Stats) GetSequentialCounter(name string) (SequentialCounter, error)

func (*Stats) MustGetGaugeCounter

func (s *Stats) MustGetGaugeCounter(name string) GaugeCounter

func (*Stats) MustGetSequentialCounter

func (s *Stats) MustGetSequentialCounter(name string) SequentialCounter

func (*Stats) RegisterGaugeCounter

func (s *Stats) RegisterGaugeCounter(name, description string) GaugeCounter

func (*Stats) RegisterSequentialCounter

func (s *Stats) RegisterSequentialCounter(name, description string) SequentialCounter

func (*Stats) Registry

func (s *Stats) Registry() Registry

func (*Stats) WithRegistry

func (s *Stats) WithRegistry(registry Registry) *Stats

Jump to

Keyboard shortcuts

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