Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(config Metrics, options ...FactoryOption) error
Types ¶
type Counter ¶
type Counter interface { Loadable // Incr will increment the counter by 1 Incr(ctx context.Context, opts ...MeasurementOption) error // Add will add the given addend to the counter Add(ctx context.Context, addend float64, opts ...MeasurementOption) error }
type DefaultCounter ¶
type DefaultCounter struct {
// contains filtered or unexported fields
}
func (*DefaultCounter) Add ¶
func (c *DefaultCounter) Add(ctx context.Context, addend float64, opts ...MeasurementOption) error
func (*DefaultCounter) Incr ¶
func (c *DefaultCounter) Incr(ctx context.Context, opts ...MeasurementOption) error
func (*DefaultCounter) Load ¶
func (c *DefaultCounter) Load(opts ...MeasurementOption)
type DefaultGauge ¶
type DefaultGauge struct {
// contains filtered or unexported fields
}
func (*DefaultGauge) Load ¶
func (g *DefaultGauge) Load(opts ...MeasurementOption)
func (*DefaultGauge) Measure ¶
func (g *DefaultGauge) Measure(ctx context.Context, value float64, opts ...MeasurementOption) error
type DefaultHistogram ¶
type DefaultHistogram struct {
// contains filtered or unexported fields
}
func (*DefaultHistogram) Load ¶
func (h *DefaultHistogram) Load(opts ...MeasurementOption)
func (*DefaultHistogram) Record ¶
func (h *DefaultHistogram) Record(ctx context.Context, measurement float64, opts ...MeasurementOption) error
type DefaultMetricsFactory ¶
type DefaultMetricsFactory struct {
// contains filtered or unexported fields
}
func (*DefaultMetricsFactory) NewCounter ¶
func (mf *DefaultMetricsFactory) NewCounter(name string, opts ...MetricOption) (Counter, error)
NewCounter will produce a Counter for measuring values that go up
It will create a new counter on first invocation, or return a cached counter previously created by name
func (*DefaultMetricsFactory) NewGauge ¶
func (mf *DefaultMetricsFactory) NewGauge(name string, opts ...MetricOption) (Gauge, error)
NewGauge will produce a Gauge for setting an instantaneous value
It will create a new gauge on first invocation, or return a cached gauge previously created by name
func (*DefaultMetricsFactory) NewHistogram ¶
func (mf *DefaultMetricsFactory) NewHistogram(name string, opts ...MetricOption) (Histogram, error)
NewHistogram will produce a Histogram for observing values
It will create a new histogram on first invocation, or return a cached histogram
type Factory ¶
type Factory interface { NewCounter(name string, opts ...MetricOption) (Counter, error) NewHistogram(name string, opts ...MetricOption) (Histogram, error) NewGauge(name string, opts ...MetricOption) (Gauge, error) }
var DefaultFactory Factory
type FactoryOption ¶
type FactoryOption func(*factoryOpts)
func WithFactory ¶
func WithFactory(factory Factory) FactoryOption
WithFactory allows providing a custom factory to be used as the DefaultFactory
func WithStaticLabel ¶
func WithStaticLabel(label, value string) FactoryOption
WithStaticLabel allows setting labels that will be set on all metrics created with the factory
type Loadable ¶
type Loadable interface { // Load will load the Metric with the MeasurementOption provided Load(opts ...MeasurementOption) }
Loadable is a behavior where measurement options can be loaded prior to measuring with the metric
type MeasurementOption ¶
type MeasurementOption func(*metricOpts)
func WithLabel ¶
func WithLabel(k, v string) MeasurementOption
WithLabel applies a label to the measurement being requested
If multiple WithLabel are applied with the same key, the last entry will be respected
type MetricOption ¶
type MetricOption func(*metricOpts)
func WithDescription ¶
func WithDescription(desc string) MetricOption
WithDescription set the description of the metric.
func WithHistogramBucketsBounds ¶
func WithHistogramBucketsBounds(buckets ...float64) MetricOption
WithHistogramBucketsBounds allows to override the default bucket boundaries for a histogram
func WithLabelNames ¶
func WithLabelNames(labels []string) MetricOption
WithLabelNames sets the labels expected to be provided to the metric.
Subsequent WithLabelNames will overwrite the previous set of names passed in. Labels passed in that were not provided as a LabelName will be ignored. Labels not passed in that were expected will result in an error being returned. // TODO <- This could also just fill in -?
func WithStaticLabels ¶
func WithStaticLabels(labels map[string]string) MetricOption
WithStaticLabels set static labels which will always export by the metric
func WithUnit ¶
func WithUnit(unit string) MetricOption
WithUnit sets units of the measurement.
The unit u should be defined using the appropriate [UCUM](https://ucum.org) case-sensitive code.