delay_counter

package
v0.0.0-...-42829d4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayOutput

type DelayOutput struct {
	Interval    int
	KeyPrefix   string
	ProgramName string

	CurrTime string
	Current  DelaySummary

	PastTime string
	Past     DelaySummary
}

DelayOutput is designed for json output

func (*DelayOutput) GetJson

func (d *DelayOutput) GetJson() ([]byte, error)

get json string for DelayOutput

func (*DelayOutput) GetKV

func (d *DelayOutput) GetKV() []byte

get key-value string for DelayOutput, without program name

func (*DelayOutput) GetKVWithProgramName

func (d *DelayOutput) GetKVWithProgramName() []byte

GetKVStringWithProgramName gets key-value string for DelayOutput, with program name

func (*DelayOutput) GetPrometheusFormat

func (d *DelayOutput) GetPrometheusFormat() []byte

func (*DelayOutput) Sum

func (d *DelayOutput) Sum(d2 DelayOutput) error

Sum calculates sum of DelayOutput

type DelayRecent

type DelayRecent struct {

	// for key-value output
	KeyPrefix   string // prefix for key
	ProgramName string // program name
	// contains filtered or unexported fields
}

func (*DelayRecent) Add

func (t *DelayRecent) Add(duration int64)

Add adds one new data to the table.

Params:

  • duration: delay duration, in Microsecond (10^-6)

func (*DelayRecent) AddBySub

func (t *DelayRecent) AddBySub(start time.Time, end time.Time)

AddBySub adds one new data to the table, by providing start time and end time

func (*DelayRecent) AddDuration

func (t *DelayRecent) AddDuration(duration time.Duration)

AddDuration adds one new data to the table.

Params:

  • duration: time duration of delay (in Nanosecond)

func (*DelayRecent) Clear

func (t *DelayRecent) Clear()

Clear clears counters

func (*DelayRecent) FormatOutput

func (t *DelayRecent) FormatOutput(params map[string][]string) ([]byte, error)

FormatOutput formats output according to format value in params

func (*DelayRecent) Get

func (t *DelayRecent) Get() DelayOutput

Get gets counter from table

func (*DelayRecent) GetJson

func (t *DelayRecent) GetJson() ([]byte, error)

GetJson gets data in the table, return with json string

func (*DelayRecent) GetKV

func (t *DelayRecent) GetKV() []byte

get data in the table, return with key-value string (i.e., lines of key:value)

func (*DelayRecent) GetKVWithProgramName

func (t *DelayRecent) GetKVWithProgramName() []byte

get data in the table, return with key-value string, with program name

func (*DelayRecent) GetPrometheusFormat

func (t *DelayRecent) GetPrometheusFormat() []byte

get data in the table, return with prometheus format

func (*DelayRecent) Init

func (t *DelayRecent) Init(interval int, bucketSize int, bucketNum int)

Init initializes delay table

Params:

  • interval: interval for move current to past
  • bucketSize: size of each delay bucket, e.g., 1(ms) or 2(ms)
  • number of bucket

func (*DelayRecent) SetKeyPrefix

func (t *DelayRecent) SetKeyPrefix(prefix string)

SetKeyPrefix sets prefix used in key generation

func (*DelayRecent) SetProgramName

func (t *DelayRecent) SetProgramName(programName string)

SetProgramName sets program name used in key generation

type DelaySummary

type DelaySummary struct {
	BucketSize int // size of each delay bucket, e.g., 1(ms) or 2(ms)
	BucketNum  int // number of bucket

	Count int64 // total number of samples
	Sum   int64 // in Microsecond
	Ave   int64 // in Microsecond

	// Counters are counters for each bucket
	// e.g., for bucketSize == 1ms, BucketNum == 5, counters are for 0-1, 1-2, 2-3, 3-4, 4-5, >5
	Counters []int64
}

DelaySummary holds data in recent several seconds

func (*DelaySummary) Add

func (dc *DelaySummary) Add(duration int64)

Add adds one new data to DelaySummary. duration is in Microsecond (10^-6)

func (*DelaySummary) CalcAvg

func (dc *DelaySummary) CalcAvg()

CalcAvg calculates average for DelaySummary

func (*DelaySummary) Clear

func (dc *DelaySummary) Clear()

Clear clears counters

func (*DelaySummary) Copy

func (dc *DelaySummary) Copy(src DelaySummary)

Copy makes a copy of src DelaySummary

func (*DelaySummary) Init

func (dc *DelaySummary) Init(bucketSize int, bucketNum int)

Init initializes DelaySummary

func (*DelaySummary) KVString

func (dc *DelaySummary) KVString(buf *bytes.Buffer, prefix string)

KVString returns key-value string (i.e., lines of key:value) for DelaySummary

Params:

  • buf: buf to write string
  • prefix: prefix add to key, e.g., prefix='Past', key='Sum', output='Past_Sum'

func (*DelaySummary) PrometheusString

func (dc *DelaySummary) PrometheusString(buf *bytes.Buffer, prefix string)

Jump to

Keyboard shortcuts

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