metrics

package
v0.0.0-...-66c35ad Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PublishType_File   = "file"
	PublishType_Falcon = "falcon"
)

Variables

This section is empty.

Functions

func NewCounter

func NewCounter() gometrics.Counter

func NewGauge

func NewGauge() gometrics.Gauge

func NewHistogram

func NewHistogram(reservoirSize int) gometrics.Histogram

func NewMeter

func NewMeter() gometrics.Meter

func NewUniformSample

func NewUniformSample(reservoirSize int) gometrics.Sample

NewUniformSample constructs a new uniform sample with the given reservoir size.

func Register

func Register(name string, metric interface{}) error

Types

type DrcMetric

type DrcMetric struct {
	Owner    string `json:"owner"`
	HostName string `json:"hostname"`

	Metric   string `json:"metric"`
	Endpoint string `json:"endpoint"`

	Timestamp int64 `json:"timestamp"`
	Value     int64 `json:"value"`

	// 上报间隔
	Interval int `json:"interval"`
}

Metric的数据格式

type FalconPublisher

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

FalconPublisher用于将metric写入到falcon

func NewFalconPublisher

func NewFalconPublisher(cfg FalconPublisherConfig) (*FalconPublisher, error)

func (*FalconPublisher) Close

func (o *FalconPublisher) Close() error

func (*FalconPublisher) Publish

func (o *FalconPublisher) Publish(drcMetrics []*DrcMetric) error

type FalconPublisherConfig

type FalconPublisherConfig struct {
	Url     string
	Timeout int
}

type FilePublisher

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

FilePublisher用于将metric写入本地文件

func NewFilePublisher

func NewFilePublisher(cfg FilePublisherConfig) (*FilePublisher, error)

func (*FilePublisher) Close

func (o *FilePublisher) Close() error

func (*FilePublisher) Publish

func (o *FilePublisher) Publish(drcMetrics []*DrcMetric) error

type FilePublisherConfig

type FilePublisherConfig struct {
	// 数据文件保存位置
	FileDir  string
	FileName string
}

type Publisher

type Publisher interface {
	Publish([]*DrcMetric) error
	Close() error
}

Publisher接口用于发布metric, 比如写入到文件或者上报到falcon

type Reporter

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

func NewReporter

func NewReporter(config *ReporterConfig) *Reporter

func (*Reporter) NewDrcMetric

func (o *Reporter) NewDrcMetric(metricName string, t time.Time, value int64) *DrcMetric

func (*Reporter) QuitNotify

func (o *Reporter) QuitNotify() <-chan struct{}

func (*Reporter) Start

func (o *Reporter) Start() error

func (*Reporter) Stop

func (o *Reporter) Stop() error

type ReporterConfig

type ReporterConfig struct {
	// 命名空间
	Owner string

	// 设备hostname
	HostName string

	// 实例id
	Endpoint string

	// 上报metric间隔, 以秒为单位
	Interval int

	// 上报metric的目标类型: file或者falcon
	PublishType string

	// 数据文件保存位置
	FileDir  string
	FileName string

	Url     string
	Timeout int
}

type UniformSample

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

func (*UniformSample) Clear

func (s *UniformSample) Clear()

Clear clears all samples.

func (*UniformSample) Count

func (s *UniformSample) Count() int64

Count returns the number of samples recorded, which may exceed the reservoir size.

func (*UniformSample) Max

func (s *UniformSample) Max() int64

Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.

func (*UniformSample) Mean

func (s *UniformSample) Mean() float64

Mean returns the mean of the values in the sample.

func (*UniformSample) Min

func (s *UniformSample) Min() int64

Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.

func (*UniformSample) Percentile

func (s *UniformSample) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample.

func (*UniformSample) Percentiles

func (s *UniformSample) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample.

func (*UniformSample) Size

func (s *UniformSample) Size() int

Size returns the size of the sample, which is at most the reservoir size.

func (*UniformSample) Snapshot

func (s *UniformSample) Snapshot() gometrics.Sample

Snapshot returns a read-only copy of the sample.

func (*UniformSample) StdDev

func (s *UniformSample) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*UniformSample) Sum

func (s *UniformSample) Sum() int64

Sum returns the sum of the values in the sample.

func (*UniformSample) Update

func (s *UniformSample) Update(v int64)

Update samples a new value.

func (*UniformSample) Values

func (s *UniformSample) Values() []int64

Values returns a copy of the values in the sample.

func (*UniformSample) Variance

func (s *UniformSample) Variance() float64

Variance returns the variance of the values in the sample.

Jump to

Keyboard shortcuts

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