Documentation ¶
Index ¶
- func MergeMetricPoint(ctx context.Context, m Metric, c Collectable, out chan<- MetricPoint) error
- func StreamMetricDescs(ctx context.Context, c Collectable, out chan<- MetricDesc, ...) error
- func StreamMetricPoints(ctx context.Context, c Collectable, out chan<- MetricPoint, ...) error
- type Collectable
- type CollectableArray
- func (m *CollectableArray) Collect(ctx context.Context, c chan<- MetricPoint) error
- func (m *CollectableArray) CounterWithValues(vals ...string) CounterType
- func (m *CollectableArray) Describe(ctx context.Context, c chan<- MetricDesc) error
- func (m *CollectableArray) GaugeWithValues(vals ...string) GaugeType
- func (m *CollectableArray) ObserveWithValues(vals ...string) ObserveType
- func (m *CollectableArray) Remove(vals ...string)
- func (m *CollectableArray) WithValues(vals ...string) Collectable
- type CollectableCreator
- type Counter
- type CounterArray
- type CounterType
- type FunctionCollectable
- type Gauge
- type GaugeArray
- type GaugeType
- type LabelSet
- type Metric
- type MetricDesc
- type MetricDescRegistry
- type MetricDescTransformation
- type MetricPoint
- type MetricPointTransformation
- type NamespaceRegistry
- func (n *NamespaceRegistry) Collect(ctx context.Context, points chan<- MetricPoint) error
- func (n *NamespaceRegistry) Describe(ctx context.Context, c chan<- MetricDesc) error
- func (n *NamespaceRegistry) Each(ctx context.Context, eachFunc RegistryEachFunc) error
- func (n *NamespaceRegistry) Register(c Collectable) error
- func (n *NamespaceRegistry) Unregister(c Collectable) error
- type ObserveArray
- type ObserveType
- type Registry
- type RegistryEachFunc
- type SingleCollectable
- type TDigest
- type TimeSince
- type Timer
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeMetricPoint ¶
func MergeMetricPoint(ctx context.Context, m Metric, c Collectable, out chan<- MetricPoint) error
Merge all data from `Metric` to every MetricPoint returned from `Collectable`
func StreamMetricDescs ¶
func StreamMetricDescs(ctx context.Context, c Collectable, out chan<- MetricDesc, transformations []MetricDescTransformation) error
func StreamMetricPoints ¶
func StreamMetricPoints(ctx context.Context, c Collectable, out chan<- MetricPoint, transformations []MetricPointTransformation) error
Types ¶
type Collectable ¶
type Collectable interface { Describe(context.Context, chan<- MetricDesc) error Collect(context.Context, chan<- MetricPoint) error }
Collectable is an interface that defines how to collect metrics
func NewCounter ¶
func NewCounter() Collectable
func NewGauge ¶
func NewGauge() Collectable
func NewTimeSince ¶
func NewTimeSince() Collectable
TimeSince will report the delta from time.Now() and the previous time observed
type CollectableArray ¶
type CollectableArray struct { // Base name + labelset to apply to all sub-metrics Metric // Function to create a new Value Creator CollectableCreator // Keys of all the labels allowed for metrics in this array LabelKeys []string // contains filtered or unexported fields }
Store an array of metrics.
func NewCollectableArray ¶
func NewCollectableArray(m Metric, c CollectableCreator, l []string) *CollectableArray
func (*CollectableArray) Collect ¶
func (m *CollectableArray) Collect(ctx context.Context, c chan<- MetricPoint) error
func (*CollectableArray) CounterWithValues ¶
func (m *CollectableArray) CounterWithValues(vals ...string) CounterType
func (*CollectableArray) Describe ¶
func (m *CollectableArray) Describe(ctx context.Context, c chan<- MetricDesc) error
func (*CollectableArray) GaugeWithValues ¶
func (m *CollectableArray) GaugeWithValues(vals ...string) GaugeType
func (*CollectableArray) ObserveWithValues ¶
func (m *CollectableArray) ObserveWithValues(vals ...string) ObserveType
func (*CollectableArray) Remove ¶
func (m *CollectableArray) Remove(vals ...string)
func (*CollectableArray) WithValues ¶
func (m *CollectableArray) WithValues(vals ...string) Collectable
Access it by the slice of values
type CollectableCreator ¶
type CollectableCreator func() Collectable
func NewTDigestCreator ¶
func NewTDigestCreator(quantiles []float64) CollectableCreator
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func (*Counter) Collect ¶
func (c *Counter) Collect(ctx context.Context, ch chan<- MetricPoint) error
type CounterArray ¶
type CounterArray struct {
*CollectableArray
}
func NewCounterArray ¶
func NewCounterArray(m Metric, l []string) *CounterArray
type specific array collectable
func NewCustomCounterArray ¶
func NewCustomCounterArray(m Metric, c CollectableCreator, l []string) (*CounterArray, error)
type specific array collectable
func (*CounterArray) WithValues ¶
func (g *CounterArray) WithValues(vals ...string) CounterType
type CounterType ¶
type CounterType interface {
Inc(uint64)
}
A few interfaces for user interraction with metrics. The goal here is to create a more user-friendly interface for the Array types
type FunctionCollectable ¶
type FunctionCollectable struct {
// contains filtered or unexported fields
}
func NewFunctionCollectable ¶
func NewFunctionCollectable(f func() float64) *FunctionCollectable
func (*FunctionCollectable) Collect ¶
func (f *FunctionCollectable) Collect(ctx context.Context, ch chan<- MetricPoint) error
func (*FunctionCollectable) Describe ¶
func (f *FunctionCollectable) Describe(ctx context.Context, ch chan<- MetricDesc) error
type GaugeArray ¶
type GaugeArray struct {
*CollectableArray
}
func NewCustomGaugeArray ¶
func NewCustomGaugeArray(m Metric, c CollectableCreator, l []string) (*GaugeArray, error)
type specific array collectable
func NewGaugeArray ¶
func NewGaugeArray(m Metric, l []string) *GaugeArray
type specific array collectable
func (*GaugeArray) WithValues ¶
func (g *GaugeArray) WithValues(vals ...string) GaugeType
type LabelSet ¶
func MergeLabelsDirect ¶
type MetricDescRegistry ¶
type MetricDescRegistry struct {
// contains filtered or unexported fields
}
TODO: make these mergeable
func NewMetricDescRegistry ¶
func NewMetricDescRegistry() *MetricDescRegistry
TODO: better name, we don't want to call this a registry since this doesn't implement the Registry interface
func (*MetricDescRegistry) AddOrError ¶
func (n *MetricDescRegistry) AddOrError(ds []MetricDesc) error
func (*MetricDescRegistry) Contains ¶
func (n *MetricDescRegistry) Contains(name string) bool
func (*MetricDescRegistry) List ¶
func (n *MetricDescRegistry) List() []MetricDesc
func (*MetricDescRegistry) Remove ¶
func (n *MetricDescRegistry) Remove(ds []MetricDesc)
type MetricDescTransformation ¶
type MetricDescTransformation func(*MetricDesc) (bool, error)
type MetricPoint ¶
type MetricPoint struct { Metric // Actual value Value Value // Time associated with this value (if not defined "now" is intended) Time time.Time }
Represent a snapshot of a metric at a specific point in time
func CollectOne ¶
func CollectOne(ctx context.Context, c Collectable) MetricPoint
CollectOne will get a single MetricPoint from a Collectable c
func CollectPoints ¶
func CollectPoints(ctx context.Context, c Collectable) ([]MetricPoint, error)
func (*MetricPoint) String ¶
func (m *MetricPoint) String() string
type MetricPointTransformation ¶
type MetricPointTransformation func(*MetricPoint) (bool, error)
Return bool (to send) and error
type NamespaceRegistry ¶
type NamespaceRegistry struct { Namespace string // contains filtered or unexported fields }
func NewNamespaceRegistry ¶
func NewNamespaceRegistry(n string) *NamespaceRegistry
func (*NamespaceRegistry) Collect ¶
func (n *NamespaceRegistry) Collect(ctx context.Context, points chan<- MetricPoint) error
Collect simply calls collect on all the collectables in this registry adding its namespace as a prefix to the name
func (*NamespaceRegistry) Describe ¶
func (n *NamespaceRegistry) Describe(ctx context.Context, c chan<- MetricDesc) error
func (*NamespaceRegistry) Each ¶
func (n *NamespaceRegistry) Each(ctx context.Context, eachFunc RegistryEachFunc) error
func (*NamespaceRegistry) Register ¶
func (n *NamespaceRegistry) Register(c Collectable) error
func (*NamespaceRegistry) Unregister ¶
func (n *NamespaceRegistry) Unregister(c Collectable) error
type ObserveArray ¶
type ObserveArray struct {
*CollectableArray
}
func NewCustomObserveArray ¶
func NewCustomObserveArray(m Metric, c CollectableCreator, l []string) (*ObserveArray, error)
type specific array collectable
func (*ObserveArray) WithValues ¶
func (g *ObserveArray) WithValues(vals ...string) ObserveType
type ObserveType ¶
type ObserveType interface {
Observe(float64)
}
type Registry ¶
type Registry interface { // Registries need to be collectable Collectable Register(Collectable) error Unregister(Collectable) error // called for each metric in the registry, context for cancellation and a function // which takes the name of the collectable and the collectable itself Each(context.Context, RegistryEachFunc) error }
Registry is a collection collectables with given names
type RegistryEachFunc ¶
type RegistryEachFunc func(Collectable, *MetricDescRegistry) error
type SingleCollectable ¶
type SingleCollectable struct { Metric Collectable }
TODO: move
func (*SingleCollectable) Collect ¶
func (s *SingleCollectable) Collect(ctx context.Context, c chan<- MetricPoint) error
func (*SingleCollectable) Describe ¶
func (s *SingleCollectable) Describe(ctx context.Context, c chan<- MetricDesc) error
type TDigest ¶
type TDigest struct {
// contains filtered or unexported fields
}
func NewTDigest ¶
func (*TDigest) Collect ¶
func (t *TDigest) Collect(ctx context.Context, c chan<- MetricPoint) error
type TimeSince ¶
type TimeSince struct {
// contains filtered or unexported fields
}
Metric type that will both (1) time and (2) count observations
func (*TimeSince) Collect ¶
func (t *TimeSince) Collect(ctx context.Context, c chan<- MetricPoint) error