metrics

package
v0.0.0-...-becd122 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destroy

func Destroy()

Destroy release current registry

func NewTrackRegistry

func NewTrackRegistry(trackLength int, d time.Duration, isNil bool)

NewTrackRegistry returns new TrackRegistry Each counter will be tracked every d duration Each counter track length will be trackLength items

Types

type Counter

type Counter interface {
	Clear()
	Count() int64
	Dec(int64)
	Inc(int64)
}

Counter implements int64 counter

func NewCounter

func NewCounter(isNil bool) Counter

NewCounter returns Nil or Standard counter

type NilCounter

type NilCounter struct{}

NilCounter is a no-op Counter.

func (NilCounter) Clear

func (NilCounter) Clear()

Clear is a no-op.

func (NilCounter) Count

func (NilCounter) Count() int64

Count is a no-op.

func (NilCounter) Dec

func (NilCounter) Dec(i int64)

Dec is a no-op.

func (NilCounter) Inc

func (NilCounter) Inc(i int64)

Inc is a no-op.

type StandardCounter

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

StandardCounter implements basic int64 counter with atomic ops

func (*StandardCounter) Clear

func (c *StandardCounter) Clear()

Clear clears counter

func (*StandardCounter) Count

func (c *StandardCounter) Count() int64

Count returns current counter value

func (*StandardCounter) Dec

func (c *StandardCounter) Dec(i int64)

Dec decrement current counter value

func (*StandardCounter) Inc

func (c *StandardCounter) Inc(i int64)

Inc increment current counter value

type TrackBuffer

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

TrackBuffer implements buffer of TrackItems

func NewTrackBuffer

func NewTrackBuffer(length int) *TrackBuffer

NewTrackBuffer returns new TrackBuffer

func (*TrackBuffer) Add

func (t *TrackBuffer) Add(item int64)

Add adds counter value into track

func (*TrackBuffer) GetDiffTrack

func (t *TrackBuffer) GetDiffTrack() []*TrackItem

GetDiffTrack returns current recorded diff-track

func (*TrackBuffer) GetLastDiffTrackItem

func (t *TrackBuffer) GetLastDiffTrackItem() *TrackItem

GetLastDiffTrackItem returns last tracked diff item

func (*TrackBuffer) GetLastTrackItem

func (t *TrackBuffer) GetLastTrackItem() *TrackItem

GetLastTrackItem returns last tracked item

func (*TrackBuffer) GetTrack

func (t *TrackBuffer) GetTrack() []*TrackItem

GetTrack returns current recorded track

type TrackCounter

type TrackCounter struct {
	Counter Counter
	Track   *TrackBuffer
}

TrackCounter implement counter with tracked values

func AddCounter

func AddCounter(name string) *TrackCounter

AddCounter add counter into registry andd return it TODO check if already exists

func GetCounter

func GetCounter(name string) *TrackCounter

GetCounter returns counter by name

func NewTrackCounter

func NewTrackCounter(trackLength int, isNil bool) *TrackCounter

NewTrackCounter returns new TrackCounter

type TrackItem

type TrackItem struct {
	Value     int64 `json:"value"`
	Timestamp int64 `json:"timestamp"`
}

TrackItem implements tracked item with value and timestamp

type TrackRegistry

type TrackRegistry struct {
	Counters map[string]*TrackCounter
	// contains filtered or unexported fields
}

TrackRegistry is a registry of track counters or other track metrics

Jump to

Keyboard shortcuts

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