Documentation ¶
Index ¶
- type DelayOutput
- type DelayRecent
- func (t *DelayRecent) Add(duration int64)
- func (t *DelayRecent) AddBySub(start time.Time, end time.Time)
- func (t *DelayRecent) AddDuration(duration time.Duration)
- func (t *DelayRecent) Clear()
- func (t *DelayRecent) FormatOutput(params map[string][]string) ([]byte, error)
- func (t *DelayRecent) Get() DelayOutput
- func (t *DelayRecent) GetJson() ([]byte, error)
- func (t *DelayRecent) GetKV() []byte
- func (t *DelayRecent) GetKVWithProgramName() []byte
- func (t *DelayRecent) GetPrometheusFormat() []byte
- func (t *DelayRecent) Init(interval int, bucketSize int, bucketNum int)
- func (t *DelayRecent) SetKeyPrefix(prefix string)
- func (t *DelayRecent) SetProgramName(programName string)
- type DelaySummary
- func (dc *DelaySummary) Add(duration int64)
- func (dc *DelaySummary) CalcAvg()
- func (dc *DelaySummary) Clear()
- func (dc *DelaySummary) Copy(src DelaySummary)
- func (dc *DelaySummary) Init(bucketSize int, bucketNum int)
- func (dc *DelaySummary) KVString(buf *bytes.Buffer, prefix string)
- func (dc *DelaySummary) PrometheusString(buf *bytes.Buffer, prefix string)
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) FormatOutput ¶
func (t *DelayRecent) FormatOutput(params map[string][]string) ([]byte, error)
FormatOutput formats output according to format value in params
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) 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)