Documentation ¶
Overview ¶
The `value` package contains the types for holding individual metric values (either just a float64 or the numeric state for a histogram). These values have no information about labels. (The label names are held in a LabelSet and the list of values for an individual metric are encoded as a RuneList which is only used as the key to a map[label.RuneList]value.Metric.)
Index ¶
- func Populate(metricMap map[label.RuneList]Metric, metricKind mon.MetricKind, ...)
- func StampEpoch(stamp string) int64
- type Histogram
- type Metric
- type RwHistogram
- type RwMetric
- type RwSimple
- type Simple
- func (sv *Simple) AsReadOnly() Metric
- func (sv *Simple) Copy(samplePeriod time.Duration) Metric
- func (sv *Simple) Export(metricKind mon.MetricKind, valueType mon.ValueType, ls *label.Set, ...) (m dto.Metric)
- func (sv *Simple) Float() float64
- func (sv *Simple) GcpEpoch() int64
- func (_ *Simple) IsReadOnly() bool
- func (sv *Simple) PromEpoch() int64
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Populate ¶
func Populate( metricMap map[label.RuneList]Metric, metricKind mon.MetricKind, valueType mon.ValueType, scaler func(float64) float64, ls *label.Set, subBuckets []int, ts *sd.TimeSeries, pt *sd.Point, )
Populate() takes a GCP metric value (*TimeSeries) and computes a label.RuneList from the label values (both metric and resource labels) and converts the numeric data to a value.Metric and then stores that in the metricMap using the RuneList as the key.
func StampEpoch ¶
Converts a timestamp string into Unix epoch seconds.
Types ¶
type Histogram ¶
A value.Histogram holds the current state of a histogram metric. It implmenets the value.Metric interface. It is read-only (but can be converted into a value.RwHistogram).
func (*Histogram) AsReadOnly ¶
func (*Histogram) Export ¶
func (hv *Histogram) Export( metricKind mon.MetricKind, valueType mon.ValueType, ls *label.Set, rl label.RuneList, bounds []float64, ) dto.Metric
Histogram's Export() returns a Protobuf version of a histogram metric.
func (*Histogram) IsReadOnly ¶
type Metric ¶
type Metric interface { // Export() constructs a dto.Metric from a value.Metric, the label names // in a label.Set, and the label values encoded in a label.RuneList. Export( metricKind mon.MetricKind, valueType mon.ValueType, ls *label.Set, rl label.RuneList, bounds []float64, ) dto.Metric // Copy() returns a deep, read-only copy of a value.Metric. Copy(time.Duration) Metric // Float() returns the float64 value of the value.Metric (for histograms, // this is the sum of the observations). Float() float64 // GcpEpoch() returns the Unix epoch seconds of the "end" timestamp of // the metric as reported by GCP. This usually equals the end of the // most recent available sample period (except for Gauge metrics that // usually have metric values with startTime == endTime and sometimes // multiple such values in a single sample period). // GcpEpoch() int64 // IsReadOnly() returns true if the value is a read-only copy. It // returns false if the value can receive updates. IsReadOnly() bool // AsReadOnly() returns the invocant but type-cast to be read-only. AsReadOnly() Metric }
A value.Metric is the interface for a single metric value.
type RwHistogram ¶
type RwHistogram struct{ Histogram }
A value.RwHistogram is a value.Histogram that can receive updates.
func (*RwHistogram) AddFloat ¶
func (hv *RwHistogram) AddFloat(f float64)
func (*RwHistogram) Convert ¶
func (hv *RwHistogram) Convert( subBuckets []int, dv *sd.Distribution, ) float64
Convert() converts a GCP Distribution value into a Prometheus histogram value which is then added to the invoking value.RwHistogram. The sum of the (new) observations is returned so the caller can scale it and then add it in as well.
func (*RwHistogram) IsReadOnly ¶
func (_ *RwHistogram) IsReadOnly() bool
func (*RwHistogram) SetEpoch ¶
func (hv *RwHistogram) SetEpoch(e int64)
type RwMetric ¶
A value.RwMetric is the interface to a value.Metric that also supports receiving updates.
type RwSimple ¶
type RwSimple struct{ Simple }
A value.RwSimple is a value.Simple that can receive updates.
func (*RwSimple) IsReadOnly ¶
type Simple ¶
type Simple struct {
// contains filtered or unexported fields
}
A value.Simple just contains a float64 metric value and a timestamp. It implmenets the value.Metric interface. It is read-only (but can be converted into a value.RwSimple).
func (*Simple) AsReadOnly ¶
func (*Simple) Export ¶
func (sv *Simple) Export( metricKind mon.MetricKind, valueType mon.ValueType, ls *label.Set, rl label.RuneList, _ []float64, ) (m dto.Metric)
Simple's Export() returns a Protobuf version of a simple metric.