Documentation ¶
Index ¶
- Constants
- func NewSpackEncoder(ctx context.Context, compression CompressionType, metrics *Metrics, ...) *spackEncoder
- func Rated(s interface{})
- func WithTags(tags map[string]string) func(*MetricsOpts)
- func WithTimestamp(t time.Time) func(*MetricsOpts)
- func WithUseNameTag() func(*MetricsOpts)
- func WithVersion12() func(*spackEncoder)
- type CompressionType
- type Counter
- type CounterVec
- type DurationHistogramVec
- type FuncCounter
- type FuncGauge
- type FuncIntGauge
- type Gauge
- type GaugeVec
- type Histogram
- func (h *Histogram) InitBucketValues(bucketValues []int64)
- func (h *Histogram) MarshalJSON() ([]byte, error)
- func (h *Histogram) Name() string
- func (h *Histogram) RecordDuration(value time.Duration)
- func (h *Histogram) RecordValue(value float64)
- func (h *Histogram) Reset()
- func (h *Histogram) Snapshot() Metric
- type HistogramVec
- type IntGauge
- type IntGaugeVec
- type Metric
- type MetricOpt
- type Metrics
- type MetricsOpts
- type Registry
- func (r Registry) ComposeName(parts ...string) string
- func (r Registry) Counter(name string) metrics.Counter
- func (r *Registry) CounterVec(name string, labels []string) metrics.CounterVec
- func (r Registry) DurationHistogram(name string, buckets metrics.DurationBuckets) metrics.Timer
- func (r *Registry) DurationHistogramVec(name string, buckets metrics.DurationBuckets, labels []string) metrics.TimerVec
- func (r Registry) FuncCounter(name string, function func() int64) metrics.FuncCounter
- func (r Registry) FuncGauge(name string, function func() float64) metrics.FuncGauge
- func (r Registry) FuncIntGauge(name string, function func() int64) metrics.FuncIntGauge
- func (r Registry) Gather() (*Metrics, error)
- func (r Registry) Gauge(name string) metrics.Gauge
- func (r *Registry) GaugeVec(name string, labels []string) metrics.GaugeVec
- func (r Registry) Histogram(name string, buckets metrics.Buckets) metrics.Histogram
- func (r *Registry) HistogramVec(name string, buckets metrics.Buckets, labels []string) metrics.HistogramVec
- func (r Registry) IntGauge(name string) metrics.IntGauge
- func (r *Registry) IntGaugeVec(name string, labels []string) metrics.IntGaugeVec
- func (r Registry) Rated(rated bool) metrics.Registry
- func (r Registry) RemoveMetric(name string)
- func (r *Registry) Stream(ctx context.Context, w io.Writer) (written int, err error)
- func (r *Registry) StreamJSON(ctx context.Context, w io.Writer) (written int, err error)
- func (r *Registry) StreamSpack(ctx context.Context, w io.Writer, compression CompressionType) (int, error)
- func (r Registry) Timer(name string) metrics.Timer
- func (r *Registry) TimerVec(name string, labels []string) metrics.TimerVec
- func (r Registry) WithPrefix(prefix string) metrics.Registry
- func (r Registry) WithTags(tags map[string]string) metrics.Registry
- type RegistryOpts
- func (o *RegistryOpts) AddCollectors(ctx context.Context, c metrics.CollectPolicy, collectors ...collect.Func) *RegistryOpts
- func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts
- func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts
- func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts
- func (o *RegistryOpts) SetRated(rated bool) *RegistryOpts
- func (o *RegistryOpts) SetSeparator(separator rune) *RegistryOpts
- func (o *RegistryOpts) SetStreamFormat(format StreamFormat) *RegistryOpts
- func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts
- func (o *RegistryOpts) SetUseNameTag(useNameTag bool) *RegistryOpts
- type SpackOpts
- type StreamFormat
- type Timer
- type TimerVec
Constants ¶
const HeaderSize = 24
Variables ¶
This section is empty.
Functions ¶
func NewSpackEncoder ¶
func NewSpackEncoder(ctx context.Context, compression CompressionType, metrics *Metrics, opts ...SpackOpts) *spackEncoder
func Rated ¶
func Rated(s interface{})
Rated marks given Solomon metric or vector as rated. Example:
cnt := r.Counter("mycounter") Rated(cnt) cntvec := r.CounterVec("mycounter", []string{"mytag"}) Rated(cntvec)
For additional info: https://m.yandex-team.ru/docs/concepts/data-model#rate
func WithTags ¶
func WithTags(tags map[string]string) func(*MetricsOpts)
func WithTimestamp ¶
func WithTimestamp(t time.Time) func(*MetricsOpts)
func WithUseNameTag ¶
func WithUseNameTag() func(*MetricsOpts)
func WithVersion12 ¶
func WithVersion12() func(*spackEncoder)
Types ¶
type CompressionType ¶
type CompressionType uint8
const ( CompressionNone CompressionType = 0x0 CompressionZlib CompressionType = 0x1 CompressionZstd CompressionType = 0x2 CompressionLz4 CompressionType = 0x3 )
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter tracks monotonically increasing value.
func (*Counter) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type CounterVec ¶
type CounterVec struct {
// contains filtered or unexported fields
}
CounterVec stores counters and implements metrics.CounterVec interface.
type DurationHistogramVec ¶
type DurationHistogramVec struct {
// contains filtered or unexported fields
}
DurationHistogramVec stores duration histograms and implements metrics.TimerVec interface.
func (*DurationHistogramVec) Reset ¶
func (v *DurationHistogramVec) Reset()
Reset deletes all metrics in this vector.
type FuncCounter ¶
type FuncCounter struct {
// contains filtered or unexported fields
}
FuncCounter tracks int64 value returned by function.
func (*FuncCounter) Function ¶
func (c *FuncCounter) Function() func() int64
func (*FuncCounter) MarshalJSON ¶
func (c *FuncCounter) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*FuncCounter) Name ¶
func (c *FuncCounter) Name() string
func (*FuncCounter) Snapshot ¶
func (c *FuncCounter) Snapshot() Metric
Snapshot returns independent copy on metric.
type FuncGauge ¶
type FuncGauge struct {
// contains filtered or unexported fields
}
FuncGauge tracks float64 value returned by function.
func (*FuncGauge) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type FuncIntGauge ¶
type FuncIntGauge struct {
// contains filtered or unexported fields
}
FuncIntGauge tracks int64 value returned by function.
func (*FuncIntGauge) Function ¶
func (g *FuncIntGauge) Function() func() int64
func (*FuncIntGauge) MarshalJSON ¶
func (g *FuncIntGauge) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*FuncIntGauge) Name ¶
func (g *FuncIntGauge) Name() string
func (*FuncIntGauge) Snapshot ¶
func (g *FuncIntGauge) Snapshot() Metric
Snapshot returns independent copy on metric.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge tracks single float64 value.
func (*Gauge) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type GaugeVec ¶
type GaugeVec struct {
// contains filtered or unexported fields
}
GaugeVec stores gauges and implements metrics.GaugeVec interface.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
func (*Histogram) InitBucketValues ¶
InitBucketValues cleans internal bucketValues and saves new values in order. Length of internal bucketValues stays unchanged. If length of slice in argument bucketValues more than length of internal one, the first extra element of bucketValues is stored in infValue.
func (*Histogram) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Histogram) RecordDuration ¶
func (*Histogram) RecordValue ¶
type HistogramVec ¶
type HistogramVec struct {
// contains filtered or unexported fields
}
HistogramVec stores histograms and implements metrics.HistogramVec interface.
func (*HistogramVec) Reset ¶
func (v *HistogramVec) Reset()
Reset deletes all metrics in this vector.
type IntGauge ¶
type IntGauge struct {
// contains filtered or unexported fields
}
IntGauge tracks single int64 value.
func (*IntGauge) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type IntGaugeVec ¶
type IntGaugeVec struct {
// contains filtered or unexported fields
}
IntGaugeVec stores gauges and implements metrics.IntGaugeVec interface.
type Metric ¶
type Metric interface { json.Marshaler Name() string Snapshot() Metric // contains filtered or unexported methods }
Metric is an any abstract solomon Metric.
type MetricOpt ¶
type MetricOpt func(*MetricsOpts)
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func PrometheusMetrics ¶
func PrometheusMetrics(metrics []*dto.MetricFamily) (*Metrics, error)
PrometheusMetrics converts Prometheus metrics to Solomon metrics.
func (Metrics) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (Metrics) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Metrics) SplitToChunks ¶
SplitToChunks splits Metrics into a slice of chunks, each at most maxChunkSize long. The length of returned slice is always at least one. Zero maxChunkSize denotes unlimited chunk length.
type MetricsOpts ¶
type MetricsOpts struct {
// contains filtered or unexported fields
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(opts *RegistryOpts) *Registry
func (Registry) ComposeName ¶
ComposeName builds FQ name with appropriate separator.
func (*Registry) CounterVec ¶
func (r *Registry) CounterVec(name string, labels []string) metrics.CounterVec
CounterVec creates a new counters vector with given metric name and partitioned by the given label names.
func (Registry) DurationHistogram ¶
func (*Registry) DurationHistogramVec ¶
func (r *Registry) DurationHistogramVec(name string, buckets metrics.DurationBuckets, labels []string) metrics.TimerVec
DurationHistogramVec creates a new duration histograms vector with given metric name and buckets and partitioned by the given label names.
func (Registry) FuncCounter ¶
func (r Registry) FuncCounter(name string, function func() int64) metrics.FuncCounter
func (Registry) FuncIntGauge ¶
func (r Registry) FuncIntGauge(name string, function func() int64) metrics.FuncIntGauge
func (*Registry) GaugeVec ¶
GaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.
func (*Registry) HistogramVec ¶
func (r *Registry) HistogramVec(name string, buckets metrics.Buckets, labels []string) metrics.HistogramVec
HistogramVec creates a new histograms vector with given metric name and buckets and partitioned by the given label names.
func (*Registry) IntGaugeVec ¶
func (r *Registry) IntGaugeVec(name string, labels []string) metrics.IntGaugeVec
IntGaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.
func (Registry) RemoveMetric ¶
func (*Registry) StreamJSON ¶
func (*Registry) StreamSpack ¶
func (*Registry) TimerVec ¶
TimerVec creates a new timers vector with given metric name and partitioned by the given label names.
func (Registry) WithPrefix ¶
WithPrefix creates new sub-scope, where each metric has prefix added to it name.
type RegistryOpts ¶
type RegistryOpts struct { Separator rune Prefix string Tags map[string]string Rated bool UseNameTag bool Collectors []func(metrics.Registry) StreamFormat StreamFormat }
func NewRegistryOpts ¶
func NewRegistryOpts() *RegistryOpts
NewRegistryOpts returns new initialized instance of RegistryOpts
func (*RegistryOpts) AddCollectors ¶
func (o *RegistryOpts) AddCollectors( ctx context.Context, c metrics.CollectPolicy, collectors ...collect.Func, ) *RegistryOpts
AddCollectors adds collectors that handle their metrics automatically (e.g. system metrics).
func (*RegistryOpts) AddTags ¶
func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts
AddTags merges given tags with existing
func (*RegistryOpts) AppendPrefix ¶
func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts
AppendPrefix adds given prefix as postfix to existing using separator
func (*RegistryOpts) SetPrefix ¶
func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts
SetPrefix overrides existing prefix
func (*RegistryOpts) SetRated ¶
func (o *RegistryOpts) SetRated(rated bool) *RegistryOpts
SetRated overrides existing rated flag
func (*RegistryOpts) SetSeparator ¶
func (o *RegistryOpts) SetSeparator(separator rune) *RegistryOpts
SetSeparator overrides existing separator
func (*RegistryOpts) SetStreamFormat ¶
func (o *RegistryOpts) SetStreamFormat(format StreamFormat) *RegistryOpts
SetStreamFormat sets default sensors stream format
func (*RegistryOpts) SetTags ¶
func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts
SetTags overrides existing tags
func (*RegistryOpts) SetUseNameTag ¶
func (o *RegistryOpts) SetUseNameTag(useNameTag bool) *RegistryOpts
SetUseNameTag overrides current UseNameTag opt
type StreamFormat ¶
type StreamFormat string
const ( StreamSpack StreamFormat = "spack" StreamJSON StreamFormat = "json" )
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer measures gauge duration.
func (*Timer) MarshalJSON ¶
MarshalJSON implements json.Marshaler.