Documentation

Overview

    Package metric support for gauge and cumulative metrics.

    This is an EXPERIMENTAL package, and may change in arbitrary ways without notice.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Float64Cumulative

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

      Float64Cumulative represents a float64 value that can only go up.

      Float64Cumulative maintains a float64 value for each combination of label values passed to the Set or Inc methods.

      func (*Float64Cumulative) GetEntry

      func (c *Float64Cumulative) GetEntry(labelVals ...metricdata.LabelValue) (*Float64CumulativeEntry, error)

        GetEntry returns a cumulative entry where each key for this cumulative has the value given.

        The number of label values supplied must be exactly the same as the number of keys supplied when this cumulative was created.

        type Float64CumulativeEntry

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

          Float64CumulativeEntry represents a single value of the cumulative corresponding to a set of label values.

          func (*Float64CumulativeEntry) Inc

          func (e *Float64CumulativeEntry) Inc(val float64)

            Inc increments the cumulative entry value by val. It returns without incrementing if the val is negative.

            type Float64DerivedCumulative

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

              Float64DerivedCumulative represents float64 cumulative value that is derived from an object.

              Float64DerivedCumulative maintains objects for each combination of label values. These objects implement Float64DerivedCumulativeInterface to read instantaneous value representing the object.

              func (*Float64DerivedCumulative) UpsertEntry

              func (c *Float64DerivedCumulative) UpsertEntry(fn func() float64, labelVals ...metricdata.LabelValue) error

                UpsertEntry inserts or updates a derived cumulative entry for the given set of label values. The object for which this cumulative entry is inserted or updated, must implement func() float64

                It returns an error if 1. The number of label values supplied are not the same as the number of keys supplied when this cumulative was created. 2. fn func() float64 is nil.

                type Float64DerivedGauge

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

                  Float64DerivedGauge represents float64 gauge value that is derived from an object.

                  Float64DerivedGauge maintains objects for each combination of label values. These objects implement Float64DerivedGaugeInterface to read instantaneous value representing the object.

                  func (*Float64DerivedGauge) UpsertEntry

                  func (g *Float64DerivedGauge) UpsertEntry(fn func() float64, labelVals ...metricdata.LabelValue) error

                    UpsertEntry inserts or updates a derived gauge entry for the given set of label values. The object for which this gauge entry is inserted or updated, must implement func() float64

                    It returns an error if 1. The number of label values supplied are not the same as the number of keys supplied when this gauge was created. 2. fn func() float64 is nil.

                    type Float64Entry

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

                      Float64Entry represents a single value of the gauge corresponding to a set of label values.

                      func (*Float64Entry) Add

                      func (e *Float64Entry) Add(val float64)

                        Add increments the gauge entry value by val.

                        func (*Float64Entry) Set

                        func (e *Float64Entry) Set(val float64)

                          Set sets the gauge entry value to val.

                          type Float64Gauge

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

                            Float64Gauge represents a float64 value that can go up and down.

                            Float64Gauge maintains a float64 value for each combination of of label values passed to the Set or Add methods.

                            func (*Float64Gauge) GetEntry

                            func (g *Float64Gauge) GetEntry(labelVals ...metricdata.LabelValue) (*Float64Entry, error)

                              GetEntry returns a gauge entry where each key for this gauge has the value given.

                              The number of label values supplied must be exactly the same as the number of keys supplied when this gauge was created.

                              type Int64Cumulative

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

                                Int64Cumulative represents a int64 cumulative value that can only go up.

                                Int64Cumulative maintains an int64 value for each combination of label values passed to the Set or Inc methods.

                                func (*Int64Cumulative) GetEntry

                                func (c *Int64Cumulative) GetEntry(labelVals ...metricdata.LabelValue) (*Int64CumulativeEntry, error)

                                  GetEntry returns a cumulative entry where each key for this cumulative has the value given.

                                  The number of label values supplied must be exactly the same as the number of keys supplied when this cumulative was created.

                                  type Int64CumulativeEntry

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

                                    Int64CumulativeEntry represents a single value of the cumulative corresponding to a set of label values.

                                    func (*Int64CumulativeEntry) Inc

                                    func (e *Int64CumulativeEntry) Inc(val int64)

                                      Inc increments the current cumulative entry value by val. It returns without incrementing if the val is negative.

                                      type Int64DerivedCumulative

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

                                        Int64DerivedCumulative represents int64 cumulative value that is derived from an object.

                                        Int64DerivedCumulative maintains objects for each combination of label values. These objects implement Int64DerivedCumulativeInterface to read instantaneous value representing the object.

                                        func (*Int64DerivedCumulative) UpsertEntry

                                        func (c *Int64DerivedCumulative) UpsertEntry(fn func() int64, labelVals ...metricdata.LabelValue) error

                                          UpsertEntry inserts or updates a derived cumulative entry for the given set of label values. The object for which this cumulative entry is inserted or updated, must implement func() int64

                                          It returns an error if 1. The number of label values supplied are not the same as the number of keys supplied when this cumulative was created. 2. fn func() int64 is nil.

                                          type Int64DerivedGauge

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

                                            Int64DerivedGauge represents int64 gauge value that is derived from an object.

                                            Int64DerivedGauge maintains objects for each combination of label values. These objects implement Int64DerivedGaugeInterface to read instantaneous value representing the object.

                                            func (*Int64DerivedGauge) UpsertEntry

                                            func (g *Int64DerivedGauge) UpsertEntry(fn func() int64, labelVals ...metricdata.LabelValue) error

                                              UpsertEntry inserts or updates a derived gauge entry for the given set of label values. The object for which this gauge entry is inserted or updated, must implement func() int64

                                              It returns an error if 1. The number of label values supplied are not the same as the number of keys supplied when this gauge was created. 2. fn func() int64 is nil.

                                              type Int64Gauge

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

                                                Int64Gauge represents a int64 gauge value that can go up and down.

                                                Int64Gauge maintains an int64 value for each combination of label values passed to the Set or Add methods.

                                                func (*Int64Gauge) GetEntry

                                                func (g *Int64Gauge) GetEntry(labelVals ...metricdata.LabelValue) (*Int64GaugeEntry, error)

                                                  GetEntry returns a gauge entry where each key for this gauge has the value given.

                                                  The number of label values supplied must be exactly the same as the number of keys supplied when this gauge was created.

                                                  type Int64GaugeEntry

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

                                                    Int64GaugeEntry represents a single value of the gauge corresponding to a set of label values.

                                                    func (*Int64GaugeEntry) Add

                                                    func (e *Int64GaugeEntry) Add(val int64)

                                                      Add increments the current gauge entry value by val, which may be negative.

                                                      func (*Int64GaugeEntry) Set

                                                      func (e *Int64GaugeEntry) Set(val int64)

                                                        Set sets the value of the gauge entry to the provided value.

                                                        type Options

                                                        type Options func(*metricOptions)

                                                          Options apply changes to metricOptions.

                                                          func WithConstLabel

                                                          func WithConstLabel(constLabels map[metricdata.LabelKey]metricdata.LabelValue) Options

                                                            WithConstLabel applies provided constant label.

                                                            func WithDescription

                                                            func WithDescription(desc string) Options

                                                              WithDescription applies provided description.

                                                              func WithLabelKeys

                                                              func WithLabelKeys(keys ...string) Options

                                                                WithLabelKeys applies provided label.

                                                                func WithLabelKeysAndDescription

                                                                func WithLabelKeysAndDescription(labelKeys ...metricdata.LabelKey) Options

                                                                  WithLabelKeysAndDescription applies provided label.

                                                                  func WithUnit

                                                                  func WithUnit(unit metricdata.Unit) Options

                                                                    WithUnit applies provided unit.

                                                                    type Registry

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

                                                                      Registry creates and manages a set of gauges and cumulative. External synchronization is required if you want to add gauges and cumulative to the same registry from multiple goroutines.

                                                                      func NewRegistry

                                                                      func NewRegistry() *Registry

                                                                        NewRegistry initializes a new Registry.

                                                                        func (*Registry) AddFloat64Cumulative

                                                                        func (r *Registry) AddFloat64Cumulative(name string, mos ...Options) (*Float64Cumulative, error)

                                                                          AddFloat64Cumulative creates and adds a new float64-valued cumulative to this registry.

                                                                          func (*Registry) AddFloat64DerivedCumulative

                                                                          func (r *Registry) AddFloat64DerivedCumulative(name string, mos ...Options) (*Float64DerivedCumulative, error)

                                                                            AddFloat64DerivedCumulative creates and adds a new derived float64-valued gauge to this registry. A derived cumulative is convenient form of cumulative where the object associated with the cumulative provides its value by implementing func() float64.

                                                                            func (*Registry) AddFloat64DerivedGauge

                                                                            func (r *Registry) AddFloat64DerivedGauge(name string, mos ...Options) (*Float64DerivedGauge, error)

                                                                              AddFloat64DerivedGauge creates and adds a new derived float64-valued gauge to this registry. A derived gauge is convenient form of gauge where the object associated with the gauge provides its value by implementing func() float64.

                                                                              func (*Registry) AddFloat64Gauge

                                                                              func (r *Registry) AddFloat64Gauge(name string, mos ...Options) (*Float64Gauge, error)

                                                                                AddFloat64Gauge creates and adds a new float64-valued gauge to this registry.

                                                                                func (*Registry) AddInt64Cumulative

                                                                                func (r *Registry) AddInt64Cumulative(name string, mos ...Options) (*Int64Cumulative, error)

                                                                                  AddInt64Cumulative creates and adds a new int64-valued cumulative to this registry.

                                                                                  func (*Registry) AddInt64DerivedCumulative

                                                                                  func (r *Registry) AddInt64DerivedCumulative(name string, mos ...Options) (*Int64DerivedCumulative, error)

                                                                                    AddInt64DerivedCumulative creates and adds a new derived int64-valued cumulative to this registry. A derived cumulative is convenient form of cumulative where the object associated with the cumulative provides its value by implementing func() int64.

                                                                                    func (*Registry) AddInt64DerivedGauge

                                                                                    func (r *Registry) AddInt64DerivedGauge(name string, mos ...Options) (*Int64DerivedGauge, error)

                                                                                      AddInt64DerivedGauge creates and adds a new derived int64-valued gauge to this registry. A derived gauge is convenient form of gauge where the object associated with the gauge provides its value by implementing func() int64.

                                                                                      func (*Registry) AddInt64Gauge

                                                                                      func (r *Registry) AddInt64Gauge(name string, mos ...Options) (*Int64Gauge, error)

                                                                                        AddInt64Gauge creates and adds a new int64-valued gauge to this registry.

                                                                                        Example
                                                                                        Output:
                                                                                        
                                                                                        

                                                                                        func (*Registry) Read

                                                                                        func (r *Registry) Read() []*metricdata.Metric

                                                                                          Read reads all gauges and cumulatives in this registry and returns their values as metrics.

                                                                                          Directories

                                                                                          Path Synopsis
                                                                                          Package metricdata contains the metrics data model.
                                                                                          Package metricdata contains the metrics data model.
                                                                                          Package metricexport contains support for exporting metric data.
                                                                                          Package metricexport contains support for exporting metric data.
                                                                                          Package test for testing code instrumented with the metric and stats packages.
                                                                                          Package test for testing code instrumented with the metric and stats packages.