metric

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metric

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

Metric contains all information needed to create a string representation of the accumulated metric data.

func NewMetric

func NewMetric(name string, options ...MetricOption) (*Metric, error)

NewMetric creates a new metric with a mandatory name and options. At least one value option must be set.

func (Metric) Serialize

func (m Metric) Serialize() (string, error)

Serialize creates the string representation of the Metric object. Will return an error if the serialization fails, or if the line length after serialization exceeds the maximum line length accepted by the ingest API.

type MetricOption

type MetricOption func(m *Metric) error

MetricOption represents the function interface used to set options on the metric object.

func WithCurrentTime

func WithCurrentTime() MetricOption

WithCurrentTime sets the current time as timestamp for the metric.

func WithDimensions

func WithDimensions(dims dimensions.NormalizedDimensionList) MetricOption

WithDimensions sets the passed dimension list as the dimensions to export. Pass only dimension lists that have been de-duplicated (by dimensions.MergeLists)

func WithFloatCounterValueDelta

func WithFloatCounterValueDelta(val float64) MetricOption

WithFloatCounterValueDelta sets a value on the metric that will be formatted as "count,delta=<value>" Returns an error if a value is already set, or if the value is NaN or Infinity.

func WithFloatGaugeValue

func WithFloatGaugeValue(val float64) MetricOption

WithFloatGaugeValue sets a gauge value on the metric that will be formatted as "gauge,<value>" Retruns an error if the value is already set or if the value is NaN or Infinity.

func WithFloatSummaryValue

func WithFloatSummaryValue(min, max, sum float64, count int64) MetricOption
WithFloatSummaryValue sets a summary statistic on the metric that will be formatted as

"gauge,min=<min>,max=<max>,sum=<sum>,count=<count>". Returns an error if the count is below 0, if min is greater than max, if a value is already set, or if any of min, max, or sum are NaN or infinite.

func WithIntCounterValueDelta

func WithIntCounterValueDelta(val int64) MetricOption

WithIntCounterValueDelta sets a value on the metric that will be formatted as "count,delta=<value>" Returns an error if a value is already set.

func WithIntGaugeValue

func WithIntGaugeValue(val int64) MetricOption

WithIntGaugeValue sets a gauge value on the metric that will be formatted as "gauge,<value>" Returns an error if a value is already set.

func WithIntSummaryValue

func WithIntSummaryValue(min, max, sum, count int64) MetricOption

WithIntSummaryValue sets a summary statistic on the metric that will be formatted as "gauge,min=<min>,max=<max>,sum=<sum>,count=<count>". Returns an error if the count is below 0, if a value is already set, or if min is greater than max.

func WithPrefix

func WithPrefix(prefix string) MetricOption

WithPrefix sets the prefix for Metric creation.

func WithTimestamp

func WithTimestamp(t time.Time) MetricOption

WithTimestamp sets a specific timestamp for the metric. If the timestamp represents a time before 2000 or after 3000, no timestamp is set and the server timestamp will be used upon ingestion. This might be case if seconds or microseconds are set as milliseconds upon timestamp creation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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