metrq

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregationFunc

type AggregationFunc = genq.AggregationFunc[float64]

func Max

func Max() AggregationFunc

func Mean

func Mean() AggregationFunc

func Median

func Median() AggregationFunc

func Min

func Min() AggregationFunc

func StatsAggregation

func StatsAggregation(f func(input stats.Float64Data) (float64, error)) AggregationFunc

func Sub

func Sub() AggregationFunc

Sub subtracts sum of all sets after the first one from the first set.

func Sum

func Sum() AggregationFunc

type Attribute

type Attribute struct {
	Key   string
	Value string
}

type Attributes

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

func NewAttributes

func NewAttributes(attrs ...Attribute) Attributes

NewAttributes creates Attributes object. The order of attrs should be deterministic (e.g. sorted alphabetically by key).

func (Attributes) Get

func (a Attributes) Get(name string) string

func (Attributes) Key

func (a Attributes) Key() AttributesKey

type AttributesKey

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

AttributesKey can be used as a map key.

func NewAttributesKey

func NewAttributesKey(attrs ...Attribute) AttributesKey

type Filter

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

func NewFilter

func NewFilter(fn FilterFunc, source Source) Filter

func (Filter) And

func (f Filter) And(operands ...genq.FilterFunc[Metric]) Filter

func (Filter) Group

func (f Filter) Group(fn GroupFunc) Group[string]

func (Filter) Metrics

func (f Filter) Metrics() Metrics

func (Filter) Or

func (f Filter) Or(operands ...genq.FilterFunc[Metric]) Filter

func (Filter) Resolve

func (f Filter) Resolve() []Metric

func (Filter) Where

func (f Filter) Where(operands ...genq.FilterFunc[Metric]) Filter

type FilterFunc

type FilterFunc = genq.FilterFunc[Metric]

func And

func And(operands ...FilterFunc) FilterFunc

func Attr

func Attr(name string, value string) FilterFunc

func False

func False() FilterFunc

func Kind

func Kind(kind MetricKind) FilterFunc

func Name

func Name(name string) FilterFunc

func NonZero

func NonZero() FilterFunc

func Not

func Not(fn FilterFunc) FilterFunc

func Or

func Or(operands ...FilterFunc) FilterFunc

func Prefix

func Prefix(prefix string) FilterFunc

func Scope

func Scope(scope string) FilterFunc

func True

func True() FilterFunc

type Group

type Group[K comparable] struct {
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup[K comparable](fn genq.GroupFunc[K, Metric], sources ...Source) Group[K]

func (Group[K]) Aggregate

func (a Group[K]) Aggregate(fn AggregationFunc) map[K]Metric

func (Group[K]) AggregateFlat

func (a Group[K]) AggregateFlat(fn AggregationFunc) Metrics

func (Group[K]) Float

func (a Group[K]) Float(fn AggregationFunc) map[K]float64

func (Group[K]) FloatSum

func (a Group[K]) FloatSum() map[K]float64

func (Group[K]) Int

func (a Group[K]) Int(fn AggregationFunc) map[K]int64

func (Group[K]) IntSum

func (a Group[K]) IntSum() map[K]int64

type GroupFunc

type GroupFunc = genq.GroupFunc[string, Metric]

func ByAttr

func ByAttr(name string) GroupFunc

func ByName

func ByName() GroupFunc

type Metric

type Metric struct {
	Scope       string
	Name        string
	Description string
	Attributes  Attributes

	Kind MetricKind

	// Value is a counter or gauge value.
	// When the metric is histogram, value is set to the sum of all histogram measurements.
	// This makes histogram measurements easier to work with
	Value float64

	// Count is a number or histogram samples
	Count uint64
	// BucketCounts store how many samples are placed into each bound
	BucketCounts []uint64
	// Bounds is a set of histogram sample bounds.
	// Bound values are absolute, and this slice should be sorted ASC
	Bounds []float64
}

Metric is a distinct metric, identified by: - scope - name - unique set of attributes Each metric could be either: 1. Counter / gauge 2. Histogram observation

func (Metric) Clone

func (m Metric) Clone() Metric

func (Metric) Key

func (m Metric) Key() MetricKey

type MetricAggregationFunc

type MetricAggregationFunc = genq.AggregationFunc[Metric]

type MetricKey

type MetricKey struct {
	Scope         string
	Name          string
	AttributesKey AttributesKey
}

type MetricKind

type MetricKind int
const (
	KindCounter MetricKind = iota + 1
	KindGauge
	KindHistogram
)

type Metrics

type Metrics []Metric

func (Metrics) Add

func (m Metrics) Add(sets ...Source) Metrics

func (Metrics) First

func (m Metrics) First() *Metric

func (Metrics) FloatSum

func (m Metrics) FloatSum() float64

func (Metrics) Floats

func (m Metrics) Floats() []float64

func (Metrics) Group

func (m Metrics) Group(fn GroupFunc) Group[string]

func (Metrics) IntSum

func (m Metrics) IntSum() int64

func (Metrics) Ints

func (m Metrics) Ints() []int64

func (Metrics) Merge

func (m Metrics) Merge(with ...Source) Group[MetricKey]

func (Metrics) Resolve

func (m Metrics) Resolve() []Metric

func (Metrics) Sub

func (m Metrics) Sub(sets ...Source) Metrics

func (Metrics) Where

func (m Metrics) Where(operands ...FilterFunc) Filter

type Source

type Source = genq.Source[Metric]

Jump to

Keyboard shortcuts

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