type ValueType … const _ … const CounterValue … const GaugeValue … const UntypedValue … var CounterMetricTypePtr … var GaugeMetricTypePtr … var UntypedMetricTypePtr … func (v ValueType) ToDTO() *dto.MetricType { … } type valueFunc … // newValueFunc returns a newly allocated valueFunc with the given Desc and // ValueType. The value reported is determined by calling the given function // from within the Write method. Take into account that metric collection may // happen concurrently. If that results in concurrent calls to Write, like in // the case where a valueFunc is directly registered with Prometheus, the // provided function must be concurrency-safe. func newValueFunc(desc *Desc, valueType ValueType, function func() float64) *valueFunc { … } func (v *valueFunc) Desc() *Desc { … } func (v *valueFunc) Write(out *dto.Metric) error { … } // NewConstMetric returns a metric with one fixed value that cannot be // changed. Users of this package will not have much use for it in regular // operations. However, when implementing custom Collectors, it is useful as a // throw-away metric that is generated on the fly to send it to Prometheus in // the Collect method. NewConstMetric returns an error if the length of // labelValues is not consistent with the variable labels in Desc or if Desc is // invalid. func NewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues ...string) (Metric, error) { … } // MustNewConstMetric is a version of NewConstMetric that panics where // NewConstMetric would have returned an error. func MustNewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues ...string) Metric { … } // NewConstMetricWithCreatedTimestamp does the same thing as NewConstMetric, but generates Counters // with created timestamp set and returns an error for other metric types. func NewConstMetricWithCreatedTimestamp(desc *Desc, valueType ValueType, value float64, ct time.Time, labelValues ...string) (Metric, error) { … } // MustNewConstMetricWithCreatedTimestamp is a version of NewConstMetricWithCreatedTimestamp that panics where // NewConstMetricWithCreatedTimestamp would have returned an error. func MustNewConstMetricWithCreatedTimestamp(desc *Desc, valueType ValueType, value float64, ct time.Time, labelValues ...string) Metric { … } type constMetric … func (m *constMetric) Desc() *Desc { … } func (m *constMetric) Write(out *dto.Metric) error { … } func populateMetric( t ValueType, v float64, labelPairs []*dto.LabelPair, e *dto.Exemplar, m *dto.Metric, ct *timestamppb.Timestamp, ) error { … } // MakeLabelPairs is a helper function to create protobuf LabelPairs from the // variable and constant labels in the provided Desc. The values for the // variable labels are defined by the labelValues slice, which must be in the // same order as the corresponding variable labels in the Desc. // // This function is only needed for custom Metric implementations. See MetricVec // example. func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair { … } const ExemplarMaxRunes … // newExemplar creates a new dto.Exemplar from the provided values. An error is // returned if any of the label names or values are invalid or if the total // number of runes in the label names and values exceeds ExemplarMaxRunes. func newExemplar(value float64, ts time.Time, l Labels) (*dto.Exemplar, error) { … }