Documentation ¶
Index ¶
- Constants
- func GetCurrentMilliseconds(startTime time.Time) int64
- type AddBucketFunc
- type Bucket
- type BucketOperation
- type GaugeOperation
- type IntervalType
- type ResMetricArray
- type SliceWindow
- func (s *SliceWindow) AddGauge(gauge model.InstanceGauge, operation AddBucketFunc) int64
- func (s *SliceWindow) AddGaugeAdvance(gauge model.InstanceGauge, operation AddBucketFunc) (int64, int64)
- func (s *SliceWindow) AddGaugeByValue(value int64, curTime time.Time) int64
- func (s *SliceWindow) AddGaugeByValueByMillTime(value int64, curTime int64) int64
- func (s *SliceWindow) AddHistoryMetric(now time.Time, operation BucketOperation) (int64, bool)
- func (s *SliceWindow) AddHistoryMetricByMillTime(now int64, operation BucketOperation) (int64, bool)
- func (s *SliceWindow) CalcMetrics(dimension int, timeRange *TimeRange) int64
- func (s *SliceWindow) CalcMetricsInMultiDimensions(dimensions []int, timeRange *TimeRange) []int64
- func (s *SliceWindow) CalcStartTime(curTime int64) int64
- func (s *SliceWindow) GetBucketInterval() time.Duration
- func (s *SliceWindow) GetLastUpdateTime() int64
- func (s *SliceWindow) IsMetricUpdate() bool
- func (s *SliceWindow) SetLastReadTime()
- func (s *SliceWindow) SetPeriodStart(now int64)
- type TimeRange
Constants ¶
const ( // Before . Before int = iota // Inside . Inside // After . After )
Variables ¶
This section is empty.
Functions ¶
func GetCurrentMilliseconds ¶
GetCurrentMilliseconds 获取当前的相对毫秒值
Types ¶
type AddBucketFunc ¶
type AddBucketFunc func(gauge model.InstanceGauge, bucket *Bucket) int64
AddBucketFunc 回调函数,用于将统计数据入桶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket 统计单元
func (*Bucket) CalcBucketMetrics ¶
func (b *Bucket) CalcBucketMetrics(dimensions []int, startTime int64, endTime int64, rangeType IntervalType) []int64
CalcBucketMetrics 计算时间范围内的桶的统计值,如果这个桶包括在时间范围内,那么计算,否则不计入
type GaugeOperation ¶
type GaugeOperation struct { Gauge model.InstanceGauge Operation AddBucketFunc }
GaugeOperation 封装类型,封装统计数据,以及添加统计的操作回调
type IntervalType ¶
type IntervalType int
IntervalType timeRange的类型
const ( // IncludeStart . IncludeStart IntervalType = iota // IncludeEnd . IncludeEnd // IncludeBoth . IncludeBoth )
type ResMetricArray ¶
type ResMetricArray struct {
// contains filtered or unexported fields
}
ResMetricArray 资源统计序列
func NewResMetricArray ¶
func NewResMetricArray(metricSize int) *ResMetricArray
NewResMetricArray 创建资源统计序列
func (*ResMetricArray) AddMetric ¶
func (r *ResMetricArray) AddMetric(dimension int, value int64) int64
AddMetric 累加统计值
func (*ResMetricArray) GetMetric ¶
func (r *ResMetricArray) GetMetric(dimension int) int64
GetMetric 获取统计值
func (*ResMetricArray) SetMetric ¶
func (r *ResMetricArray) SetMetric(dimension int, value int64)
SetMetric 重置统计值
func (*ResMetricArray) SwapMetric ¶
func (r *ResMetricArray) SwapMetric(dimension int, newValue int64) int64
SwapMetric .交换统计
type SliceWindow ¶
type SliceWindow struct { // 滑窗所属的类型,一般为插件名 Type string Lock *sync.Mutex // 周期开始时间 PeriodStartTime int64 // contains filtered or unexported fields }
SliceWindow 滑窗
func NewSliceWindow ¶
func NewSliceWindow(typ string, bucketCount int, bucketInterval time.Duration, metricSize int, curTime int64) *SliceWindow
NewSliceWindow 创建资源滑窗
func (*SliceWindow) AddGauge ¶
func (s *SliceWindow) AddGauge(gauge model.InstanceGauge, operation AddBucketFunc) int64
AddGauge 添加统计数据
func (*SliceWindow) AddGaugeAdvance ¶
func (s *SliceWindow) AddGaugeAdvance(gauge model.InstanceGauge, operation AddBucketFunc) (int64, int64)
AddGaugeAdvance 添加统计数据,返回就近的数据以及bucket起始时间
func (*SliceWindow) AddGaugeByValue ¶
func (s *SliceWindow) AddGaugeByValue(value int64, curTime time.Time) int64
AddGaugeByValue 添加统计数据
func (*SliceWindow) AddGaugeByValueByMillTime ¶
func (s *SliceWindow) AddGaugeByValueByMillTime(value int64, curTime int64) int64
AddGaugeByValueByMillTime 添加统计数据
func (*SliceWindow) AddHistoryMetric ¶
func (s *SliceWindow) AddHistoryMetric(now time.Time, operation BucketOperation) (int64, bool)
AddHistoryMetric 添加历史数据 返回函数运行结果,以及是否命中
func (*SliceWindow) AddHistoryMetricByMillTime ¶
func (s *SliceWindow) AddHistoryMetricByMillTime(now int64, operation BucketOperation) (int64, bool)
AddHistoryMetricByMillTime 添加历史数据
func (*SliceWindow) CalcMetrics ¶
func (s *SliceWindow) CalcMetrics(dimension int, timeRange *TimeRange) int64
CalcMetrics 计算维度下所有的时间段的值之和
func (*SliceWindow) CalcMetricsInMultiDimensions ¶
func (s *SliceWindow) CalcMetricsInMultiDimensions(dimensions []int, timeRange *TimeRange) []int64
CalcMetricsInMultiDimensions 计算多个维度下的统计值
func (*SliceWindow) CalcStartTime ¶
func (s *SliceWindow) CalcStartTime(curTime int64) int64
CalcStartTime 计算对应bucket起始时间戳
func (*SliceWindow) GetBucketInterval ¶
func (s *SliceWindow) GetBucketInterval() time.Duration
GetBucketInterval 获取滑桶的长度
func (*SliceWindow) GetLastUpdateTime ¶
func (s *SliceWindow) GetLastUpdateTime() int64
GetLastUpdateTime 获取最近更新时间
func (*SliceWindow) IsMetricUpdate ¶
func (s *SliceWindow) IsMetricUpdate() bool
IsMetricUpdate 判断是否在上次读取了数据后,又有数据更新
func (*SliceWindow) SetLastReadTime ¶
func (s *SliceWindow) SetLastReadTime()
SetLastReadTime 设置最近读取时间
func (*SliceWindow) SetPeriodStart ¶
func (s *SliceWindow) SetPeriodStart(now int64)
SetPeriodStart 根据当前时间设置周期开始时间