statistics

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const TypeCounter = "counter"

计数器,得到 counter

View Source
const TypeData = "data"

任意数据

View Source
const TypeSamples = "samples"

采样,得到 counter, max, min, avg

Variables

This section is empty.

Functions

This section is empty.

Types

type ReportItem

type ReportItem struct {
	Type    string      `json:"type"`    // 统计类型
	Tag     string      `json:"tag"`     // 标签
	Counter int32       `json:"counter"` // 计数
	Min     int32       `json:"min"`     // 最小值
	Max     int32       `json:"max"`     // 最大值
	Avg     float64     `json:"avg"`     // 平均值
	Data    interface{} `json:"data"`    // 数据
}

type Statistics

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

func New

func New() *Statistics

func (*Statistics) Add

func (s *Statistics) Add(tag string, n int32) *Statistics

添加采样数据

func (*Statistics) Decr

func (s *Statistics) Decr(tag string) *Statistics

减计数

func (*Statistics) DecrN

func (s *Statistics) DecrN(tag string, n int32) *Statistics

减计数

func (*Statistics) Flush

func (s *Statistics) Flush()

清空统计信息(一般与 report() 配合使用)

func (*Statistics) Get

func (s *Statistics) Get(tag string) (TagItem, bool)

获取指定标签的数据

func (*Statistics) Incr

func (s *Statistics) Incr(tag string) *Statistics

增加计数

func (*Statistics) IncrN

func (s *Statistics) IncrN(tag string, n int32) *Statistics

增加计数

func (*Statistics) Init

func (s *Statistics) Init(itemType string, tag string, title string)

初始化标签

func (*Statistics) Report

func (s *Statistics) Report(flush bool) []ReportItem

获得当前报告

func (*Statistics) Set

func (s *Statistics) Set(tag string, data interface{}) *Statistics

设置数据

func (*Statistics) Watch

func (s *Statistics) Watch(interval time.Duration, callback func(list []ReportItem)) (cancel func())

监听数据报告

type SyncStatistics

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

并发安全版本

func NewSync

func NewSync() *SyncStatistics

func (*SyncStatistics) Add

func (s *SyncStatistics) Add(tag string, n int32) *SyncStatistics

添加采样数据

func (*SyncStatistics) Decr

func (s *SyncStatistics) Decr(tag string) *SyncStatistics

减计数

func (*SyncStatistics) DecrN

func (s *SyncStatistics) DecrN(tag string, n int32) *SyncStatistics

减计数

func (*SyncStatistics) Flush

func (s *SyncStatistics) Flush()

清空统计信息(一般与 report() 配合使用)

func (*SyncStatistics) Get

func (s *SyncStatistics) Get(tag string) (item TagItem, ok bool)

获取指定标签的数据

func (*SyncStatistics) Incr

func (s *SyncStatistics) Incr(tag string) *SyncStatistics

增加计数

func (*SyncStatistics) IncrN

func (s *SyncStatistics) IncrN(tag string, n int32) *SyncStatistics

增加计数

func (*SyncStatistics) Init

func (s *SyncStatistics) Init(itemType string, tag string, title string)

初始化标签

func (*SyncStatistics) Report

func (s *SyncStatistics) Report(flush bool) []ReportItem

获得当前报告

func (*SyncStatistics) Set

func (s *SyncStatistics) Set(tag string, data interface{}) *SyncStatistics

设置数据

func (*SyncStatistics) Watch

func (s *SyncStatistics) Watch(interval time.Duration, callback func(list []ReportItem)) (cancel func())

监听数据报告

type TagItem

type TagItem struct {
	Type    string      `json:"type"`    // 统计类型
	Title   string      `json:"title"`   // 标题
	Counter int32       `json:"counter"` // 计数
	Min     int32       `json:"min"`     // 最小值
	Max     int32       `json:"max"`     // 最大值
	Avg     float64     `json:"avg"`     // 平均值
	Data    interface{} `json:"data"`    // 数据
}

Jump to

Keyboard shortcuts

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