Documentation
¶
Index ¶
- Variables
- func Counter(key string, value float64, tagKvs ...string)
- func Init(options ...Option)
- func Latency(key string, begin time.Time, tagKvs ...string)
- func SampleMax(values []int64) int64
- func SampleMean(values []int64) float64
- func SampleMin(values []int64) int64
- func SamplePercentile(values int64Slice, p float64) float64
- func SamplePercentiles(values int64Slice, ps []float64) []float64
- func SampleStdDev(values []int64) float64
- func SampleSum(values []int64) int64
- func SampleVariance(values []int64) float64
- func Store(key string, value float64, tagKvs ...string)
- func Timer(key string, value float64, tagKvs ...string)
- type Metric
- func (*Metric) Descriptor() ([]byte, []int)deprecated
- func (x *Metric) GetMetric() string
- func (x *Metric) GetTags() map[string]string
- func (x *Metric) GetTimestamp() uint64
- func (x *Metric) GetValue() float64
- func (*Metric) ProtoMessage()
- func (x *Metric) ProtoReflect() protoreflect.Message
- func (x *Metric) Reset()
- func (x *Metric) String() string
- type MetricMessage
- type Option
- type Sample
- type SampleSnapshot
- func (*SampleSnapshot) Clear()
- func (s *SampleSnapshot) Count() int64
- func (s *SampleSnapshot) Max() int64
- func (s *SampleSnapshot) Mean() float64
- func (s *SampleSnapshot) Min() int64
- func (s *SampleSnapshot) Percentile(p float64) float64
- func (s *SampleSnapshot) Percentiles(ps []float64) []float64
- func (s *SampleSnapshot) Size() int
- func (s *SampleSnapshot) Snapshot() Sample
- func (s *SampleSnapshot) StdDev() float64
- func (s *SampleSnapshot) Sum() int64
- func (*SampleSnapshot) Update(int64)
- func (s *SampleSnapshot) Values() []int64
- func (s *SampleSnapshot) Variance() float64
- type UniformSample
- func (s *UniformSample) Clear()
- func (s *UniformSample) Count() int64
- func (s *UniformSample) Max() int64
- func (s *UniformSample) Mean() float64
- func (s *UniformSample) Min() int64
- func (s *UniformSample) Percentile(p float64) float64
- func (s *UniformSample) Percentiles(ps []float64) []float64
- func (s *UniformSample) Size() int
- func (s *UniformSample) Snapshot() Sample
- func (s *UniformSample) StdDev() float64
- func (s *UniformSample) Sum() int64
- func (s *UniformSample) Update(v int64)
- func (s *UniformSample) Values() []int64
- func (s *UniformSample) Variance() float64
Constants ¶
This section is empty.
Variables ¶
var File_metrics_proto protoreflect.FileDescriptor
Functions ¶
func Counter ¶
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 ¶
Latency report time cost for execution tagKvs should be formatted as "key:value" example: metrics.Latency("request.latency", startTime, "method:user", "type:upload")
func SampleMean ¶
SampleMean returns the mean value of the slice of int64.
func SamplePercentile ¶
SamplePercentile SamplePercentiles returns an arbitrary percentile of the slice of int64.
func SamplePercentiles ¶
SamplePercentiles returns a slice of arbitrary percentiles of the slice of int64.
func SampleStdDev ¶
SampleStdDev returns the standard deviation of the slice of int64.
func SampleVariance ¶
SampleVariance returns the variance of the slice of int64.
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) GetTimestamp ¶
func (*Metric) ProtoMessage ¶
func (*Metric) ProtoMessage()
func (*Metric) ProtoReflect ¶
func (x *Metric) ProtoReflect() protoreflect.Message
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 ¶
WithFlushInterval set the interval of reporting metrics
func WithMetricsDomain ¶
func WithMetricsHttpSchema ¶
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 WithMetricsTimeout ¶
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 ¶
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) 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) 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) 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) 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.