base

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PtrSize = int(8)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketLeapArray

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

The implementation of sliding window based on LeapArray (as the sliding window infrastructure) and MetricBucket (as the data type). The MetricBucket is used to record statistic metrics per minimum time unit (i.e. the bucket time span).

func NewBucketLeapArray

func NewBucketLeapArray(sampleCount uint32, intervalInMs uint32) *BucketLeapArray

sampleCount is the number of slots intervalInMs is the time length of sliding window

func (*BucketLeapArray) AddCount

func (bla *BucketLeapArray) AddCount(event base.MetricEvent, count int64)

Write method It might panic

func (*BucketLeapArray) BucketLengthInMs

func (bla *BucketLeapArray) BucketLengthInMs() uint32

func (*BucketLeapArray) Count

func (bla *BucketLeapArray) Count(event base.MetricEvent) int64

Read method, need to adapt upper application it might panic

func (*BucketLeapArray) CountWithTime

func (bla *BucketLeapArray) CountWithTime(now uint64, event base.MetricEvent) int64

func (*BucketLeapArray) DataType

func (bla *BucketLeapArray) DataType() string

func (*BucketLeapArray) GetIntervalInSecond

func (bla *BucketLeapArray) GetIntervalInSecond() float64

func (*BucketLeapArray) IntervalInMs

func (bla *BucketLeapArray) IntervalInMs() uint32

func (*BucketLeapArray) MinRt

func (bla *BucketLeapArray) MinRt() int64

func (*BucketLeapArray) SampleCount

func (bla *BucketLeapArray) SampleCount() uint32

func (*BucketLeapArray) Values

func (bla *BucketLeapArray) Values(now uint64) []*bucketWrap

Read method, get all bucketWrap.

func (*BucketLeapArray) ValuesConditional

func (bla *BucketLeapArray) ValuesConditional(now uint64, predicate base.TimePredicate) []*bucketWrap

type MetricBucket

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

MetricBucket represents the entity to record metrics per minimum time unit (i.e. the bucket time span). Note that all operations of the MetricBucket are required to be thread-safe.

func NewMetricBucket

func NewMetricBucket() *MetricBucket

func (*MetricBucket) Add

func (mb *MetricBucket) Add(event base.MetricEvent, count int64)

Add statistic count for the given metric event.

func (*MetricBucket) AddRt

func (mb *MetricBucket) AddRt(rt int64)

func (*MetricBucket) Get

func (mb *MetricBucket) Get(event base.MetricEvent) int64

Get current statistic count of the given metric event.

func (*MetricBucket) MinRt

func (mb *MetricBucket) MinRt() int64

type SlidingWindowMetric

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

SlidingWindowMetric represents the sliding window metric wrapper. It does not store any data and is the wrapper of BucketLeapArray to adapt to different internal bucket SlidingWindowMetric is used for SentinelRules and BucketLeapArray is used for monitor BucketLeapArray is per resource, and SlidingWindowMetric support only read operation.

func NewSlidingWindowMetric

func NewSlidingWindowMetric(sampleCount, intervalInMs uint32, real *BucketLeapArray) *SlidingWindowMetric

It must pass the parameter point to the real storage entity

func (*SlidingWindowMetric) AvgRT

func (m *SlidingWindowMetric) AvgRT() float64

func (*SlidingWindowMetric) GetMaxOfSingleBucket

func (m *SlidingWindowMetric) GetMaxOfSingleBucket(event base.MetricEvent) int64

func (*SlidingWindowMetric) GetQPS

func (m *SlidingWindowMetric) GetQPS(event base.MetricEvent) float64

func (*SlidingWindowMetric) GetSum

func (m *SlidingWindowMetric) GetSum(event base.MetricEvent) int64

func (*SlidingWindowMetric) MinRT

func (m *SlidingWindowMetric) MinRT() float64

func (*SlidingWindowMetric) SecondMetricsOnCondition

func (m *SlidingWindowMetric) SecondMetricsOnCondition(predicate base.TimePredicate) []*base.MetricItem

SecondMetricsOnCondition aggregates metric items by second on condition that the startTime of the statistic buckets satisfies the time predicate.

Jump to

Keyboard shortcuts

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