stats

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry will be used to register all the MO Dev Stats.

Functions

func Register

func Register(familyName string, opts ...Options)

Register registers stats family to default stats registry familyName is a unique family name for the stats opts can contain logExporter etc. for the stats. Usage: stats.Register("FamilyName", stats.WithLogExporter(customStatsLogExporter))

func Unregister

func Unregister(familyName string)

Unregister unregisters the family from DefaultRegistry.

Types

type Counter

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

Counter represents a combination of global & current_window counter.

func (*Counter) Add

func (c *Counter) Add(delta int64) (new int64)

Add adds to global and window counter

func (*Counter) Load

func (c *Counter) Load() int64

Load return the global counter value

func (*Counter) LoadW

func (c *Counter) LoadW() int64

LoadW returns current window value

func (*Counter) Reset added in v1.0.0

func (c *Counter) Reset()

Reset reset the global and window counter to 0

func (*Counter) Swap

func (c *Counter) Swap(n int64) int64

Set swaps the global counter value

func (*Counter) SwapW

func (c *Counter) SwapW(new int64) int64

SwapW swaps current window counter with new

type Family

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

Family contains attributed related to a DevStats Family. Currently, it only has LogExporter

type LogExporter

type LogExporter interface {
	Export() []zap.Field
}

type Options

type Options func(*options)

func WithLogExporter

func WithLogExporter(logExporter LogExporter) Options

WithLogExporter registers Family with the LogExporter

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry holds mapping between FamilyName and Family

func NewRegistry

func NewRegistry() *Registry

func (*Registry) ExportLog

func (r *Registry) ExportLog() map[string][]zap.Field

ExportLog returns the snapshot of all the Family in the registry

func (*Registry) Register

func (r *Registry) Register(familyName string, opts ...Options)

func (*Registry) Unregister

func (r *Registry) Unregister(familyName string)

Unregister deletes the item with familyName from map.

Jump to

Keyboard shortcuts

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