metrics

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_volcengine_rec_sdk_metrics_proto protoreflect.FileDescriptor

Functions

func Counter

func Counter(key string, value float64, tagKvs ...string)

Counter tagKvs should be formatted as "key:value" example: metrics.Counter("request.qps", 1, "method:user", "type:upload")

func Init

func Init(options ...Option)

Init As long as the Init function is called, the metrics are enabled

func Latency

func Latency(key string, begin time.Time, tagKvs ...string)

Latency report time cost for execution tagKvs should be formatted as "key:value" example: metrics.Latency("request.latency", startTime, "method:user", "type:upload")

func SampleMax

func SampleMax(values []int64) int64

SampleMax returns the maximum value of the slice of int64.

func SampleMean

func SampleMean(values []int64) float64

SampleMean returns the mean value of the slice of int64.

func SampleMin

func SampleMin(values []int64) int64

SampleMin returns the minimum value of the slice of int64.

func SamplePercentile

func SamplePercentile(values int64Slice, p float64) float64

SamplePercentile SamplePercentiles returns an arbitrary percentile of the slice of int64.

func SamplePercentiles

func SamplePercentiles(values int64Slice, ps []float64) []float64

SamplePercentiles returns a slice of arbitrary percentiles of the slice of int64.

func SampleStdDev

func SampleStdDev(values []int64) float64

SampleStdDev returns the standard deviation of the slice of int64.

func SampleSum

func SampleSum(values []int64) int64

SampleSum returns the sum of the slice of int64.

func SampleVariance

func SampleVariance(values []int64) float64

SampleVariance returns the variance of the slice of int64.

func Store

func Store(key string, value float64, tagKvs ...string)

Store tagKvs should be formatted as "key:value" example: metrics.Store("goroutine.count", 400, "ip:127.0.0.1")

func Timer

func Timer(key string, value float64, tagKvs ...string)

Timer tagKvs should be formatted as "key:value" example: metrics.Timer("request.cost", 100, "method:user", "type:upload")

Types

type Metric

type Metric struct {
	Metric    string            `protobuf:"bytes,1,opt,name=metric,proto3" json:"metric,omitempty"`
	Timestamp uint64            `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Value     float64           `protobuf:"fixed64,3,opt,name=value,proto3" json:"value,omitempty"`
	Tags      map[string]string `` /* 149-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*Metric) Descriptor deprecated

func (*Metric) Descriptor() ([]byte, []int)

Deprecated: Use Metric.ProtoReflect.Descriptor instead.

func (*Metric) GetMetric

func (x *Metric) GetMetric() string

func (*Metric) GetTags

func (x *Metric) GetTags() map[string]string

func (*Metric) GetTimestamp

func (x *Metric) GetTimestamp() uint64

func (*Metric) GetValue

func (x *Metric) GetValue() float64

func (*Metric) ProtoMessage

func (*Metric) ProtoMessage()

func (*Metric) ProtoReflect

func (x *Metric) ProtoReflect() protoreflect.Message

func (*Metric) Reset

func (x *Metric) Reset()

func (*Metric) String

func (x *Metric) String() string

type MetricMessage

type MetricMessage struct {
	Metrics []*Metric `protobuf:"bytes,1,rep,name=metrics,proto3" json:"metrics,omitempty"`
	// contains filtered or unexported fields
}

func (*MetricMessage) Descriptor deprecated

func (*MetricMessage) Descriptor() ([]byte, []int)

Deprecated: Use MetricMessage.ProtoReflect.Descriptor instead.

func (*MetricMessage) GetMetrics

func (x *MetricMessage) GetMetrics() []*Metric

func (*MetricMessage) ProtoMessage

func (*MetricMessage) ProtoMessage()

func (*MetricMessage) ProtoReflect

func (x *MetricMessage) ProtoReflect() protoreflect.Message

func (*MetricMessage) Reset

func (x *MetricMessage) Reset()

func (*MetricMessage) String

func (x *MetricMessage) String() string

type Option

type Option func(*config)

func WithFlushInterval

func WithFlushInterval(flushInterval time.Duration) Option

WithFlushInterval set the interval of reporting metrics

func WithMetricsDomain

func WithMetricsDomain(domain string) Option

func WithMetricsHttpSchema

func WithMetricsHttpSchema(schema string) Option

WithMetricsHttpSchema in private env, 'https' may not be supported

func WithMetricsLog

func WithMetricsLog() Option

WithMetricsLog if not set, will not print metrics log

func WithMetricsPrefix

func WithMetricsPrefix(prefix string) Option

func WithMetricsTimeout

func WithMetricsTimeout(timeout time.Duration) Option

WithMetricsTimeout set the interval of reporting metrics

type Sample

type Sample interface {
	Clear()
	Count() int64
	Max() int64
	Mean() float64
	Min() int64
	Percentile(float64) float64
	Percentiles([]float64) []float64
	Size() int
	Snapshot() Sample
	StdDev() float64
	Sum() int64
	Update(int64)
	Values() []int64
	Variance() float64
}

Sample Samples maintain a statistically-significant selection of values from a stream.

func NewUniformSample

func NewUniformSample(reservoirSize int) Sample

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

type SampleSnapshot

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

SampleSnapshot is a read-only copy of another Sample.

func NewSampleSnapshot

func NewSampleSnapshot(count int64, values []int64) *SampleSnapshot

func (*SampleSnapshot) Clear

func (*SampleSnapshot) Clear()

Clear panics.

func (*SampleSnapshot) Count

func (s *SampleSnapshot) Count() int64

Count returns the count of inputs at the time the snapshot was taken.

func (*SampleSnapshot) Max

func (s *SampleSnapshot) Max() int64

Max returns the maximal value at the time the snapshot was taken.

func (*SampleSnapshot) Mean

func (s *SampleSnapshot) Mean() float64

Mean returns the mean value at the time the snapshot was taken.

func (*SampleSnapshot) Min

func (s *SampleSnapshot) Min() int64

Min returns the minimal value at the time the snapshot was taken.

func (*SampleSnapshot) Percentile

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

Percentile returns an arbitrary percentile of values at the time the snapshot was taken.

func (*SampleSnapshot) Percentiles

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

Percentiles returns a slice of arbitrary percentiles of values at the time the snapshot was taken.

func (*SampleSnapshot) Size

func (s *SampleSnapshot) Size() int

Size returns the size of the sample at the time the snapshot was taken.

func (*SampleSnapshot) Snapshot

func (s *SampleSnapshot) Snapshot() Sample

Snapshot returns the snapshot.

func (*SampleSnapshot) StdDev

func (s *SampleSnapshot) StdDev() float64

StdDev returns the standard deviation of values at the time the snapshot was taken.

func (*SampleSnapshot) Sum

func (s *SampleSnapshot) Sum() int64

Sum returns the sum of values at the time the snapshot was taken.

func (*SampleSnapshot) Update

func (*SampleSnapshot) Update(int64)

Update panics.

func (*SampleSnapshot) Values

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

Values returns a copy of the values in the sample.

func (*SampleSnapshot) Variance

func (s *SampleSnapshot) Variance() float64

Variance returns the variance of values at the time the snapshot was taken.

type UniformSample

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

UniformSample A uniform sample using Vitter's Algorithm R.

<http://www.cs.umd.edu/~samir/498/vitter.pdf>

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() 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