Documentation
¶
Overview ¶
Package stats provide a simple real-time metric registry for monitoring and observability.
Index ¶
- type DefaultGaugeCounter
- func (c *DefaultGaugeCounter) Dec(tags ...string) int64
- func (c *DefaultGaugeCounter) DecBy(delta int64, tags ...string) int64
- func (c *DefaultGaugeCounter) Inc(tags ...string) int64
- func (c *DefaultGaugeCounter) IncBy(delta int64, tags ...string) int64
- func (c *DefaultGaugeCounter) NotifyOnChange(ch chan<- any, tags ...string)
- func (c *DefaultGaugeCounter) Set(value int64, tags ...string)
- func (c *DefaultGaugeCounter) Tags() []string
- func (c *DefaultGaugeCounter) Value(tags ...string) int64
- type DefaultRegistry
- type DefaultSequentialCounter
- func (c *DefaultSequentialCounter) Inc(tags ...string) int64
- func (c *DefaultSequentialCounter) IncBy(delta int64, tags ...string) int64
- func (c *DefaultSequentialCounter) NotifyOnChange(ch chan<- any, tags ...string)
- func (c *DefaultSequentialCounter) Tags() []string
- func (c *DefaultSequentialCounter) Value(tags ...string) int64
- type GaugeCounter
- type Metric
- type Registry
- type SequentialCounter
- type Stats
- func (s *Stats) GetGaugeCounter(name string) (GaugeCounter, error)
- func (s *Stats) GetSequentialCounter(name string) (SequentialCounter, error)
- func (s *Stats) MustGetGaugeCounter(name string) GaugeCounter
- func (s *Stats) MustGetSequentialCounter(name string) SequentialCounter
- func (s *Stats) RegisterGaugeCounter(name, description string) GaugeCounter
- func (s *Stats) RegisterSequentialCounter(name, description string) SequentialCounter
- func (s *Stats) Registry() Registry
- func (s *Stats) WithRegistry(registry Registry) *Stats
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 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 (*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) WithRegistry ¶
Click to show internal directories.
Click to hide internal directories.