counter

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package counter define single or multi metric counters

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeValue

func NormalizeValue(values []interface{}) []interface{}

NormalizeValue normalize stat values

Types

type Counter

type Counter struct {
	Count  int64 `json:",omitempty"`
	Custom CustomCounter
}

Counter represents a counter

func (*Counter) CountValue

func (c *Counter) CountValue() int64

CountValue returns count

func (*Counter) Decrement

func (c *Counter) Decrement() int64

Decrement decrement counter

func (*Counter) Increment

func (c *Counter) Increment() int64

Increment increments counter

func (*Counter) IncrementBy

func (c *Counter) IncrementBy(i int64) int64

IncrementBy increments counter

type CustomCounter

type CustomCounter interface {
	Aggregate(value interface{})
}

type CustomProvider

type CustomProvider interface {
	NewCounter() CustomCounter
}

type MultiCounter

type MultiCounter struct {
	*Counter
	Counters []*Value
	// contains filtered or unexported fields
}

MultiCounter represents multi value counter

func (*MultiCounter) DecrementValue

func (c *MultiCounter) DecrementValue(value interface{}) int64

DecrementValue decrements counter by 1

func (*MultiCounter) IncrementValue

func (c *MultiCounter) IncrementValue(value interface{}) int64

IncrementValue increments counter

func (*MultiCounter) IncrementValueBy

func (c *MultiCounter) IncrementValueBy(value interface{}, i int64) int64

IncrementValueBy increments counter

type OnDone

type OnDone func(end time.Time, values ...interface{}) int64

OnDone on done callback

type Operation

type Operation struct {
	*MultiCounter
	TimeTaken int64
	Max       int64
	Min       int64
	Avg       int32
	// contains filtered or unexported fields
}

Operation represents basic metrics

func NewOperation

func NewOperation(timeUnit time.Duration, provider Provider) *Operation

NewOperation creates operation metrics

func (*Operation) Before

func (o *Operation) Before(other time.Time) bool

func (*Operation) Begin

func (o *Operation) Begin(started time.Time) OnDone

Begin begins count an event

func (*Operation) BeginWithInc

func (o *Operation) BeginWithInc(inc int64, started time.Time) OnDone

BeginWithInc begins count an event

type Provider

type Provider interface {
	//Map maps value int slice index
	Map(interface{}) int
	//Keys  returns mapped keys
	Keys() []string
}

Provider represents customized metric provider

type Value

type Value struct {
	Value string
	Counter
	Pct int32 `json:",omitempty"`
}

Value represents counter value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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