metric

package module
v0.0.0-...-4dec921 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

README

metric

GoDoc Build Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPkgs

func GetPkgs(showEmpty bool) []string

GetPkgs lista all package names

func NewClient

func NewClient(pkg, prefix string) stats.Client

NewClient creates an instance of facebookgo/stats implementation with the given pkg name and preifx.

func SetCounterParam

func SetCounterParam(window, bucket time.Duration) error

SetCounterParam sets the parameters of counter and histogram

func SetHistogramParam

func SetHistogramParam(window, bucket time.Duration) error

SetHistogramParam sets the parameters of counter and histogram

Types

type Bin

type Bin struct {
	Count int64
	Lower float64
	Upper float64
}

Bin represents the snapshot of a histogram bin, including bin couner and its lower and upper bound

type Bucket

type Bucket struct {
	Count float64
	Sum   float64
	Min   float64
	Max   float64
	Avg   float64
	Start time.Time
	End   time.Time
}

Bucket represents the snapshot of a counter bucket, including statistics values like count, sum, average, min, max and bucket start/end time.

type Counter

type Counter interface {
	// Incr increments value to the counter
	Incr(value float64)
	// Snapshot return the snapshot of the counter
	Snapshot() CounterSnapshot
}

Counter defines interface for counter

func NewCounter

func NewCounter(windowDur, bucketDur time.Duration) (Counter, error)

NewCounter creates a counter with the given paramters

type CounterSnapshot

type CounterSnapshot interface {
	// SliceIn returns statistics of each bucket in the given duration
	SliceIn(dur time.Duration) []Bucket
	// AggrIn returns aggregration statistics in the given duration
	AggrIn(dur time.Duration) Bucket
}

CounterSnapshot defines interface for accessing counter with following methods

type HistSnapshot

type HistSnapshot interface {
	// List histogram bins
	Bins() []Bin
	// Return export percentail values of the histogram
	Percentiles([]float64) ([]float64, int64)
}

HistSnapshot represents a snapshot of a histogram

type Histogram

type Histogram interface {
	// Update add value to the histogram
	Update(value float64)
	// Snapshot returns the snapshot of the histogrom
	Snapshot() HistSnapshot
}

Histogram defines interface for counter

func NewHistogram

func NewHistogram(windowDur, bucketDur time.Duration) (Histogram, error)

NewHistogram accepts StatsName, histogram parameter min, max slice, and export flag

type MockCounter

type MockCounter struct {
	mock.Mock
}

MockCounter is mock object of Counter

func (*MockCounter) Incr

func (m *MockCounter) Incr(value float64)

Incr mocks Incr()

func (*MockCounter) Snapshot

func (m *MockCounter) Snapshot() CounterSnapshot

Snapshot mocks Snapshot()

type MockCtrSnapshot

type MockCtrSnapshot struct {
	mock.Mock
}

MockCtrSnapshot is mock object of CounterSnapshot

func (*MockCtrSnapshot) AggrIn

func (m *MockCtrSnapshot) AggrIn(dur time.Duration) Bucket

AggrIn mocks AggrIn()

func (*MockCtrSnapshot) SliceIn

func (m *MockCtrSnapshot) SliceIn(dur time.Duration) []Bucket

SliceIn mocks SliceIn()

type MockHist

type MockHist struct {
	mock.Mock
}

MockHist is mock object of Histogram

func (*MockHist) Snapshot

func (m *MockHist) Snapshot() HistSnapshot

Snapshot mocks Snapshot()

func (*MockHist) Update

func (m *MockHist) Update(value float64)

Update mocks Update()

type MockHistSnapshot

type MockHistSnapshot struct {
	mock.Mock
}

MockHistSnapshot is mock object of HistogramSnapshot

func (*MockHistSnapshot) Bins

func (m *MockHistSnapshot) Bins() []Bin

Bins mocks Bins()

func (*MockHistSnapshot) Percentiles

func (m *MockHistSnapshot) Percentiles(ps []float64) ([]float64, int64)

Percentiles mocks Percentiles()

type Snapshot

type Snapshot interface {
	CounterSnapshot
	HistSnapshot
	// HasHistogram returns whether this snapshot contains histogram
	HasHistogram() bool
	// Pkg returns the package of Histogram
	Pkg() string
	// Name returns the package of Histogram Name
	Name() string
}

Snapshot includes CounterSnapshot, HistogramSnapshot and name

func GetSnapshot

func GetSnapshot(qpkg string, qname string) []Snapshot

GetSnapshot returns shapshot of counters and histograms matched the given pkg and name

Jump to

Keyboard shortcuts

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