metrics

package
v1.247.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: BSD-3-Clause, MIT Imports: 7 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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)
)
View Source
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 LabelName

type LabelName string

A LabelName is a key for a Metric.

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.

func (LabelSet) String

func (l LabelSet) String() string

type LabelValue

type LabelValue string

A LabelValue is an associated value for a MetricLabelName.

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.

func (Metric) String

func (m Metric) String() string

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 Now

func Now() Time

Now returns the current time as a Time.

func TimeFromUnix

func TimeFromUnix(t int64) Time

TimeFromUnix returns the Time equivalent to the Unix Time t provided in seconds.

func TimeFromUnixNano

func TimeFromUnixNano(t int64) Time

TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.

func (Time) Add

func (t Time) Add(d time.Duration) Time

Add returns the Time t + d.

func (Time) After

func (t Time) After(o Time) bool

After reports whether the Time t is after o.

func (Time) Before

func (t Time) Before(o Time) bool

Before reports whether the Time t is before o.

func (Time) Equal

func (t Time) Equal(o Time) bool

Equal reports whether two Times represent the same instant.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Time) String

func (t Time) String() string

String returns a string representation of the Time.

func (Time) Sub

func (t Time) Sub(o Time) time.Duration

Sub returns the Duration t - o.

func (Time) Time

func (t Time) Time() time.Time

Time returns the time.Time representation of t.

func (Time) Unix

func (t Time) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.

func (Time) UnixNano

func (t Time) UnixNano() int64

UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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