Documentation ¶
Overview ¶
Package metrics is a minimal copy of github.com/prometheus/common/model providing types to work with the Prometheus-style results in a DigitalOcean Monitoring metrics response.
Index ¶
- Constants
- type Interval
- type LabelName
- type LabelSet
- type LabelValue
- type Metric
- type SamplePair
- type SampleStream
- type SampleValue
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(o Time) bool
- func (t Time) Before(o Time) bool
- func (t Time) Equal(o Time) bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) String() string
- func (t Time) Sub(o Time) time.Duration
- func (t Time) Time() time.Time
- func (t Time) Unix() int64
- func (t Time) UnixNano() int64
- func (t *Time) UnmarshalJSON(b []byte) error
Constants ¶
const ( // Earliest is the earliest Time representable. Handy for // initializing a high watermark. Earliest = Time(math.MinInt64) // Latest is the latest Time representable. Handy for initializing // a low watermark. Latest = Time(math.MaxInt64) )
const ( // MetricNameLabel is the label name indicating the metric name of a // timeseries. MetricNameLabel = "__name__" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interval ¶
type Interval struct {
Start, End Time
}
Interval describes an interval between two timestamps.
type LabelSet ¶
type LabelSet map[LabelName]LabelValue
A LabelSet is a collection of LabelName and LabelValue pairs. The LabelSet may be fully-qualified down to the point where it may resolve to a single Metric in the data store or not. All operations that occur within the realm of a LabelSet can emit a vector of Metric entities to which the LabelSet may match.
type Metric ¶
type Metric LabelSet
A Metric is similar to a LabelSet, but the key difference is that a Metric is a singleton and refers to one and only one stream of samples.
type SamplePair ¶
type SamplePair struct { Timestamp Time Value SampleValue }
SamplePair pairs a SampleValue with a Timestamp.
func (SamplePair) MarshalJSON ¶
func (s SamplePair) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (SamplePair) String ¶
func (s SamplePair) String() string
func (*SamplePair) UnmarshalJSON ¶
func (s *SamplePair) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type SampleStream ¶
type SampleStream struct { Metric Metric `json:"metric"` Values []SamplePair `json:"values"` }
SampleStream is a stream of Values belonging to an attached COWMetric.
func (SampleStream) String ¶
func (ss SampleStream) String() string
type SampleValue ¶
type SampleValue float64
A SampleValue is a representation of a value for a given sample at a given time.
func (SampleValue) Equal ¶
func (v SampleValue) Equal(o SampleValue) bool
Equal returns true if the value of v and o is equal or if both are NaN. Note that v==o is false if both are NaN. If you want the conventional float behavior, use == to compare two SampleValues.
func (SampleValue) MarshalJSON ¶
func (v SampleValue) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (SampleValue) String ¶
func (v SampleValue) String() string
func (*SampleValue) UnmarshalJSON ¶
func (v *SampleValue) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Time ¶
type Time int64
Time is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds.
func TimeFromUnix ¶
TimeFromUnix returns the Time equivalent to the Unix Time t provided in seconds.
func TimeFromUnixNano ¶
TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Time) Unix ¶
Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
func (Time) UnixNano ¶
UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.