stats

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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