var separatorByteSlice … type Metric … type Opts … // BuildFQName joins the given three name components by "_". Empty name // components are ignored. If the name parameter itself is empty, an empty // string is returned, no matter what. Metric implementations included in this // library use this function internally to generate the fully-qualified metric // name from the name component in their Opts. Users of the library will only // need this function if they implement their own Metric or instantiate a Desc // (with NewDesc) directly. func BuildFQName(namespace, subsystem, name string) string { … } type invalidMetric … // NewInvalidMetric returns a metric whose Write method always returns the // provided error. It is useful if a Collector finds itself unable to collect // a metric and wishes to report an error to the registry. func NewInvalidMetric(desc *Desc, err error) Metric { … } func (m *invalidMetric) Desc() *Desc { … } func (m *invalidMetric) Write(*dto.Metric) error { … } type timestampedMetric … func (m timestampedMetric) Write(pb *dto.Metric) error { … } // NewMetricWithTimestamp returns a new Metric wrapping the provided Metric in a // way that it has an explicit timestamp set to the provided Time. This is only // useful in rare cases as the timestamp of a Prometheus metric should usually // be set by the Prometheus server during scraping. Exceptions include mirroring // metrics with given timestamps from other metric // sources. // // NewMetricWithTimestamp works best with MustNewConstMetric, // MustNewConstHistogram, and MustNewConstSummary, see example. // // Currently, the exposition formats used by Prometheus are limited to // millisecond resolution. Thus, the provided time will be rounded down to the // next full millisecond value. func NewMetricWithTimestamp(t time.Time, m Metric) Metric { … } type withExemplarsMetric … func (m *withExemplarsMetric) Write(pb *dto.Metric) error { … } type Exemplar … // NewMetricWithExemplars returns a new Metric wrapping the provided Metric with given // exemplars. Exemplars are validated. // // Only last applicable exemplar is injected from the list. // For example for Counter it means last exemplar is injected. // For Histogram, it means last applicable exemplar for each bucket is injected. // // NewMetricWithExemplars works best with MustNewConstMetric and // MustNewConstHistogram, see example. func NewMetricWithExemplars(m Metric, exemplars ...Exemplar) (Metric, error) { … } // MustNewMetricWithExemplars is a version of NewMetricWithExemplars that panics where // NewMetricWithExemplars would have returned an error. func MustNewMetricWithExemplars(m Metric, exemplars ...Exemplar) Metric { … }